public void WriteAccount(StAccountIDFieldCode fieldCode, AccountId value) { WriteFieldId(StTypeCode.AccountID, (uint)fieldCode); WriteLengthPrefix(20); value.CopyTo(bufferWriter.GetSpan(20)); bufferWriter.Advance(20); }
public static Hash256 CalculateId(AccountId account) { Span <byte> buffer = stackalloc byte[22]; System.Buffers.Binary.BinaryPrimitives.WriteUInt16BigEndian(buffer, 0x0061); account.CopyTo(buffer.Slice(2)); return(CalculateId(buffer)); }
public static Hash256 CalculateId(AccountId account, uint ticketSequence) { Span <byte> buffer = stackalloc byte[2 + 20 + 4]; System.Buffers.Binary.BinaryPrimitives.WriteUInt16BigEndian(buffer, 0x0054); account.CopyTo(buffer.Slice(2)); System.Buffers.Binary.BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(22), ticketSequence); return(CalculateId(buffer)); }
public static Hash256 CalculateId(AccountId owner, AccountId preauthorized) { Span <byte> buffer = stackalloc byte[42]; System.Buffers.Binary.BinaryPrimitives.WriteUInt16BigEndian(buffer, 0x0070); owner.CopyTo(buffer.Slice(2)); preauthorized.CopyTo(buffer.Slice(22)); return(CalculateId(buffer)); }
public static Hash256 CalculateId(AccountId source, AccountId destination, uint sequence) { Span <byte> buffer = stackalloc byte[46]; System.Buffers.Binary.BinaryPrimitives.WriteUInt16BigEndian(buffer, 0x0078); source.CopyTo(buffer.Slice(2)); destination.CopyTo(buffer.Slice(22)); System.Buffers.Binary.BinaryPrimitives.WriteUInt32BigEndian(buffer.Slice(42), sequence); return(CalculateId(buffer)); }
public static Hash256 CalculateId(AccountId low, AccountId high, CurrencyCode currencyCode) { Span <byte> buffer = stackalloc byte[62]; System.Buffers.Binary.BinaryPrimitives.WriteUInt16BigEndian(buffer, 0x0072); low.CopyTo(buffer.Slice(2)); high.CopyTo(buffer.Slice(22)); currencyCode.CopyTo(buffer.Slice(42)); return(CalculateId(buffer)); }
public static Hash256 CalculateOfferId(CurrencyCode takerPaysCurrency, CurrencyCode takerGetsCurrency, AccountId takerPaysIssuer, AccountId takerGetsIssuer, ulong offers) { // The first page of an Offer Directory has a special ID: the higher 192 bits define the order book, and the remaining 64 bits define the exchange rate of the offers in that directory. // (The ID is big-endian, so the book is in the more significant bits, which come first, and the quality is in the less significant bits which come last.) // This provides a way to iterate through an order book from best offers to worst.Specifically: the first 192 bits are the first 192 bits of the SHA-512Half of the following values, concatenated in order: // //The Book Directory space key(0x0042) //The 160-bit currency code from the TakerPaysCurrency //The 160-bit currency code from the TakerGetsCurrency //The AccountID from the TakerPaysIssuer //The AccountID from the TakerGetsIssuer //The lower 64 bits of an Offer Directory's ID represent the TakerPays amount divided by TakerGets amount from the offer(s) in that directory as a 64-bit number in the XRP Ledger's internal amount format. // Span <byte> buffer = stackalloc byte[38]; System.Buffers.Binary.BinaryPrimitives.WriteUInt16BigEndian(buffer, 0x0042); takerPaysCurrency.CopyTo(buffer.Slice(2)); takerGetsCurrency.CopyTo(buffer.Slice(22)); takerPaysIssuer.CopyTo(buffer.Slice(42)); takerGetsIssuer.CopyTo(buffer.Slice(62)); Hash256 hash = CalculateId(buffer); return(hash); }