/// <summary> /// Allocate an array. Intended for testing purposes only. /// </summary> internal static ProduceCoinRequest From( RequestId requestId, ClientId clientId, Outpoint outpoint, OutpointFlags flags, BlockAlias context, ulong satoshis, uint nLockTime, Span <byte> script, BlockHandleMask mask) { var request = new ProduceCoinRequest { _buffer = new Span <byte>(new byte[Header.SizeInBytes + script.Length]) }; request.MessageHeader.MessageSizeInBytes = Header.SizeInBytes + script.Length; request.MessageHeader.RequestId = requestId; request.MessageHeader.ClientId = clientId; request.MessageHeader.MessageKind = MessageKind.ProduceCoin; request.AsHeader.Outpoint = outpoint; request.AsHeader.Flags = flags; request.AsHeader.Context = context.ConvertToBlockHandle(mask); request.AsHeader.Satoshis = satoshis; request.AsHeader.NLockTime = nLockTime; script.CopyTo(request._buffer.Slice(Header.SizeInBytes)); return(request); }
public GetCoinResponse( RequestId requestId, ClientId clientId, GetCoinStatus status, ref Outpoint outpoint, OutpointFlags flags, BlockAlias context, BlockAlias production, BlockAlias consumption, ulong satoshis, uint nLockTime, Span <byte> script, BlockHandleMask mask, SpanPool <byte> pool) { var messageSizeInBytes = Header.SizeInBytes + script.Length; _buffer = pool.GetSpan(messageSizeInBytes); AsHeader.ResponseHeader.MessageSizeInBytes = messageSizeInBytes; AsHeader.ResponseHeader.RequestId = requestId; AsHeader.ResponseHeader.ClientId = clientId; AsHeader.ResponseHeader.MessageKind = MessageKind.GetCoinResponse; AsHeader.Status = status; AsHeader.Outpoint = outpoint; AsHeader.Flags = flags; AsHeader.Context = context.ConvertToBlockHandle(mask); AsHeader.Production = production.ConvertToBlockHandle(mask); AsHeader.Consumption = consumption.ConvertToBlockHandle(mask); AsHeader.Satoshis = satoshis; AsHeader.NLockTime = nLockTime; script.CopyTo(_buffer.Slice(Header.SizeInBytes)); }
public Outpoint(TxId txid, int index, int payloadLength, OutpointFlags flags) { if (payloadLength > ushort.MaxValue) { throw new ArgumentOutOfRangeException(nameof(payloadLength), "Cannot exceeds 65556 bytes."); } Txid = txid; Index = index; PayloadLength = (ushort)payloadLength; Flags = flags; }
/// <summary> Coin production. Client-side perspective. </summary> public ProduceCoinRequest( RequestId requestId, ref Outpoint outpoint, OutpointFlags flags, BlockHandle context, ulong satoshis, uint nLockTime, int scriptSizeInBytes, SpanPool <byte> pool) { _buffer = pool.GetSpan(Header.SizeInBytes + scriptSizeInBytes); _mask = default; AsHeader.RequestHeader.MessageSizeInBytes = Header.SizeInBytes + scriptSizeInBytes; AsHeader.RequestHeader.RequestId = requestId; AsHeader.RequestHeader.MessageKind = MessageKind.ProduceCoin; Outpoint = outpoint; HandleContext = context; Flags = flags; Satoshis = satoshis; NLockTime = nLockTime; }