Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: hitjariwala on January 22, 2017, 05:54:11 AM



Title: Make First Transaction using NBitcoin Library
Post by: hitjariwala on January 22, 2017, 05:54:11 AM
Hi,

I am make first transaction of 0.001 using NBitcoin Library. when i make transaction of 0.0001 it give message.
ErrorCode: INSUFFICIENTFEE Error message: insufficient priority

I am make transaction using this code.
https://github.com/NicolasDorier/ProgrammingBlockchainCodeExamples/blob/master/SpendYourCoins/Program.cs

Can any tell me how to transfer transaction fees to my address?

Thanks


Title: Re: Make First Transaction using NBitcoin Library
Post by: Coding Enthusiast on January 22, 2017, 02:23:27 PM
I think you are not using NBitcoin library (https://github.com/MetacoSA/NBitcoin) instead you are using the example code. And in that example code according to the book (https://programmingblockchain.gitbooks.io/programmingblockchain/content/bitcoin_transfer/spend_your_coin.html) it is setting the fee amount to 0.0001BTC (https://github.com/NicolasDorier/ProgrammingBlockchainCodeExamples/blob/master/SpendYourCoins/Program.cs#L66-L71) which means when you spend 0.0001BTC it deducts 0.0001 from your 0.0001 and is left with 0 (https://github.com/NicolasDorier/ProgrammingBlockchainCodeExamples/blob/master/SpendYourCoins/Program.cs#L74) so as a result it throws an exception (https://github.com/NicolasDorier/ProgrammingBlockchainCodeExamples/blob/master/SpendYourCoins/Program.cs#L110-L114)

You need to debug the program yourself to make sure, I am mainly making assumptions based on what I see from the code and your explanation.


Title: Re: Make First Transaction using NBitcoin Library
Post by: hitjariwala on January 23, 2017, 05:09:39 AM
I think you are not using NBitcoin library (https://github.com/MetacoSA/NBitcoin) instead you are using the example code. And in that example code according to the book (https://programmingblockchain.gitbooks.io/programmingblockchain/content/bitcoin_transfer/spend_your_coin.html) it is setting the fee amount to 0.0001BTC (https://github.com/NicolasDorier/ProgrammingBlockchainCodeExamples/blob/master/SpendYourCoins/Program.cs#L66-L71) which means when you spend 0.0001BTC it deducts 0.0001 from your 0.0001 and is left with 0 (https://github.com/NicolasDorier/ProgrammingBlockchainCodeExamples/blob/master/SpendYourCoins/Program.cs#L74) so as a result it throws an exception (https://github.com/NicolasDorier/ProgrammingBlockchainCodeExamples/blob/master/SpendYourCoins/Program.cs#L110-L114)

You need to debug the program yourself to make sure, I am mainly making assumptions based on what I see from the code and your explanation.

Thanks for Reply

Can you send source code for send bitcoin with fees?


Title: Re: Make First Transaction using NBitcoin Library
Post by: Coding Enthusiast on January 23, 2017, 05:51:38 AM
The code you are seeing in the example IS with fees! the variable called minerFee is the fee that you are paying and it is a fixed amount of 0.0001BTC.

Just change that line to anything you like, it can be a fixed amount or it can be a function taking the best amount of fee based on an API call such as this http://bitcoinfees.21.co/api

Or if you are doing it on top of a full node you can analyze the previous blocks to figure out the suitable fee.


Title: Re: Make First Transaction using NBitcoin Library
Post by: hitjariwala on January 23, 2017, 08:07:23 AM
The code you are seeing in the example IS with fees! the variable called minerFee is the fee that you are paying and it is a fixed amount of 0.0001BTC.

Just change that line to anything you like, it can be a fixed amount or it can be a function taking the best amount of fee based on an API call such as this http://bitcoinfees.21.co/api

Or if you are doing it on top of a full node you can analyze the previous blocks to figure out the suitable fee.

Hi,

Any give me Spend bitcoin using TransactionBuilder?