3
1
So I am creating a transaction using TransactionBuilder like this:
var builder = new TransactionBuilder();
Transaction tx = builder
.AddCoins(coins)
.AddKeys(privateKeys)
.Send(recipientAddress, Money.Coins(amount))
.SetChange(changeAddress)
.SendFees(Money.Coins(fee))
.BuildTransaction(sign: true);
Boolean verified = builder.Verify(tx);
And then I propagate it to the network like so:
using (var node = Node.ConnectToLocal(network))
{
node.VersionHandshake();
node.SendMessage(new InvPayload(InventoryType.MSG_TX, tx.GetHash()));
node.SendMessage(new TxPayload(tx));
Thread.Sleep(500);
}
I have two questions:
What does the
builder.Verify(tx)even tell us? It returns a boolean, but sometimes I can propagate transactions that returnedfalse. What does verify mean/do?Since
Verify()doesn't really tell us if a transaction will successfully propagate, how do I determine when a transaction made using TransactionBuilder will or won't propagate to the network?
I was able to propagate a transaction to the testnet that didn't properly verify. If you would like to view it, here is the hash: e98118de943d124e21d52dd6a05528eff18f199e3eea6ae149d97ce3f0158ae5 – rosstripi – 2017-02-13T16:27:44.630
I cannot find it:
– nopara73 – 2017-02-13T21:57:32.023https://testnet.smartbit.com.au/tx/e98118de943d124e21d52dd6a05528eff18f199e3eea6ae149d97ce3f015%E2%80%8C%E2%80%8B8ae5
http://tbtc.blockr.io/tx/info/e98118de943d124e21d52dd6a05528eff18f199e3eea6ae149d97ce3f0158ae5
I can just speculate at this point, but maybe the node you "propagated to" does not check the validity of the transaction, but when it wanted to propagate it further, other nodes rejected it? – nopara73 – 2017-02-13T22:00:46.150
It should accept the transaction: I'm sending it to myself, so mine is the only key needed.
Also, I'm seeing that the above transaction did go through: transaction here
It did not get propagated to the network, block explorers doesn't find it. Sending to yourself happens to the same way as sending to everyone else. You have to propagate the transaction through the whole network and it has to be stored by every full-node. I'm not sure what's going on at you locally. – nopara73 – 2017-02-13T22:06:11.450
@rossbot Apparently when you copypaste the transactionid from your first comment some magic changes it. From the
f015it inserts 2??when I paste it. (Win7, not sure that matters). This is why I did not see the transactions on the above links. – nopara73 – 2017-02-13T22:50:24.007To sum up, yes, you propagated a transaction that NBitcoin couldn't verify. That's strange. – nopara73 – 2017-02-13T22:51:25.430