NBitcoin: TransactionBuilder fails to build the change address

Hello, Just wondering why the following code does not generate the change address output:

TransactionBuilder builder = new TransactionBuilder(); builder.AddCoins(coins); builder.AddKeys(bitcoinPrivateKey); builder.Send(destinationAddress, new Money(0.000000015m, MoneyUnit.BTC)); builder.SendFees(Money.Coins(0.001m)); builder.SetChange(address.ScriptPubKey); var signedTx = builder.BuildTransaction(true); Boolean b = builder.Verify(signedTx);

What I’m missing? Transaction’s hex (Testnet):

01000000000101e38fd8de708abdb8eddd0e47d1369f44d4e2de0d5407cf277d4dfc73a0a922875300000017160014a017d15c9cfacea59c4a3984b32f2282e617de8effffffff01f6b4b600000000001976a914a017d15c9cfacea59c4a3984b32f2282e617de8e88ac02473044022028f8440e4d85eca57a99fadda133fc9ce48b523a4b4d2438aaaad0a296d8d7270220112eb54f7e8a1f311b6b4dc0a15c4b3a5311948724a8aa0657da52da6b26fc68012102b6d3f00966c6797c69b98cc7d4f7ec0e9ec8aee68f2fccb5cec061eeaee47f8900000000

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25 (6 by maintainers)

Most upvoted comments

@robermann

from: 0,12073879
fees: 0,00100001
to: 0,11973878
change: 0,0

No, it did

from: 0,12073879
fees: 0,00100001
to: 0,0
change: 0,11973878 + 0,000000015

In my opinion, the library shoud not change automatically the transaction as intended by the programmer (such as changing the values). In case of issues, it should throw an exception.