public AccountId CreatedAccount() { AccountId destination = null; Hash256 destinationIndex = null; if (TransactionType == TransactionType.Payment && Meta.Has(Field.AffectedNodes)) { StArray affected = Meta[StArray.AffectedNodes]; foreach (var node in affected) { if (node.Has(StObject.CreatedNode)) { StObject created = node[StObject.CreatedNode]; if (StObject.LedgerEntryType(created) == LedgerEntryType.AccountRoot) { if (destination == null) { destination = Txn[AccountId.Destination]; destinationIndex = Hash256.AccountIdLedgerIndex(destination); } if (destinationIndex.Equals(created[Hash256.LedgerHash])) { return(destination); } } } } } return(null); }
public void TestAccountIdLedgerIndex() { const string Addy = "rP1coskQzayaQ9geMdJgAV5f3tNZcHghzH"; const string LedgerIndex = "D66D0EC951FD5707633BEBE74DB18B6D2DDA6771BA0FBF079AD08BFDE6066056"; Hash256 expectedLedgerIndex = Hash256.OutTranslate.FromString(LedgerIndex); AccountId accountId = AccountId.FromAddress(Addy); Hash256 builtLedgerIndex = Hash256.AccountIdLedgerIndex(accountId); Assert.AreEqual(expectedLedgerIndex, builtLedgerIndex); }