private ChainedHeaderBlock CreateBlockWithVotingRequest(JoinFederationRequest votingRequest, int height) { var encoder = new JoinFederationRequestEncoder(); var votingRequestData = new List <byte>(); votingRequestData.AddRange(encoder.Encode(votingRequest)); var votingRequestOutputScript = new Script(OpcodeType.OP_RETURN, Op.GetPushOp(votingRequestData.ToArray())); Transaction tx = this.network.CreateTransaction(); tx.AddOutput(Money.COIN, votingRequestOutputScript); Block block = new Block(); block.Transactions.Add(tx); block.Header.Time = (uint)(height * (this.network.ConsensusOptions as PoAConsensusOptions).TargetSpacingSeconds); block.UpdateMerkleRoot(); block.GetHash(); return(new ChainedHeaderBlock(block, new ChainedHeader(block.Header, block.GetHash(), height))); }
private ChainedHeaderBlock CreateBlockWithVotingRequest(JoinFederationRequest votingRequest, int height) { var encoder = new JoinFederationRequestEncoder(); var votingRequestData = new List <byte>(); votingRequestData.AddRange(encoder.Encode(votingRequest)); var votingRequestOutputScript = new Script(OpcodeType.OP_RETURN, Op.GetPushOp(votingRequestData.ToArray())); Transaction tx = this.network.CreateTransaction(); tx.AddOutput(Money.COIN, votingRequestOutputScript); Block block = PoaTestHelper.CreateBlock(this.network, tx, height); return(new ChainedHeaderBlock(block, new ChainedHeader(block.Header, block.GetHash(), height))); }
public static JoinFederationRequestResult BuildTransaction(IWalletTransactionHandler walletTransactionHandler, Network network, JoinFederationRequest request, JoinFederationRequestEncoder encoder, string walletName, string walletAccount, string walletPassword) { byte[] encodedVotingRequest = encoder.Encode(request); var votingOutputScript = new Script(OpcodeType.OP_RETURN, Op.GetPushOp(encodedVotingRequest)); var context = new TransactionBuildContext(network) { AccountReference = new WalletAccountReference(walletName, walletAccount), MinConfirmations = 0, FeeType = FeeType.High, WalletPassword = walletPassword, Recipients = new[] { new Recipient { Amount = new Money(VotingRequestTransferAmount, MoneyUnit.BTC), ScriptPubKey = votingOutputScript } }.ToList() }; Transaction transaction = walletTransactionHandler.BuildTransaction(context); Guard.Assert(IsVotingRequestTransaction(transaction, encoder)); if (context.TransactionBuilder.Verify(transaction, out TransactionPolicyError[] errors))