Title: Tranfer BTC using API or using node modules Post by: rushabhmadhu on June 29, 2018, 07:34:45 AM hello,
I have created bitcoin addresses dynamically using nodejs module. I have private key and address. we want to tranfer BTC received in those dynamically generated address we have private key for it. At present we are using below nodejs code to send BTC var bitcoinTransaction = require('bitcoin-transaction'); var to = "12zyHTgqfm3XT5K9afmaPjhcwvbAYuBBHk"; var from ="1DnqKVAPB9JUxQxuc6xe9jycyvhWhu7NzS"; var privKeyWIF = "XXXX-Privatekey-XXXXXXX"; bitcoinTransaction.getBalance(from, { network: "mainnet" }).then((balanceInBTC) => { var btcToSend=parseFloat(0.0001); bitcoinTransaction.sendTransaction({ from: from, to: to, privKeyWIF: privKeyWIF, btc: 0.00000547, network: "mainnet", fees: 3, }).catch((error) => { console.log(error); }).then((result)=> { console.log(result); }); console.log(balanceInBTC); }).catch((error) => { console.log(error); }); As we have done the transaction using this code it cost me fees as 206 satoshi per byte Here is the tx : https://www.[Suspicious link removed]/en/btc/tx/2d4639266d3af9416b1f022193a3587df501a678a794744dbf8f4fddcecc3564 What i have to change to specify fixed fees for transaction. Is there any other API or node module that i can use for transfering BTC from one address to another using private key of address? Title: Re: Tranfer BTC using API or using node modules Post by: bob123 on June 29, 2018, 02:33:52 PM Is there any other API or node module that i can use for transfering BTC from one address to another using private key of address? Well, you might start with telling us the current module you are using. Usually you always can set a fee (or all the outputs including change output). https://github.com/bitcoinjs/bitcoinjs-lib (https://github.com/bitcoinjs/bitcoinjs-lib) does give you the option: Code: const txb = new bitcoin.TransactionBuilder(regtest) Source: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js#L55 (https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js#L55) Title: Re: Tranfer BTC using API or using node modules Post by: HCP on June 30, 2018, 09:17:48 AM At present we are using below nodejs code to send BTC You've set the fee wrong... as per the documentation here: https://www.npmjs.com/package/bitcoin-transaction#bitcointransactionsendtransactionoptionsvar bitcoinTransaction = require('bitcoin-transaction'); var to = "12zyHTgqfm3XT5K9afmaPjhcwvbAYuBBHk"; var from ="1DnqKVAPB9JUxQxuc6xe9jycyvhWhu7NzS"; var privKeyWIF = "XXXX-Privatekey-XXXXXXX"; bitcoinTransaction.getBalance(from, { network: "mainnet" }).then((balanceInBTC) => { var btcToSend=parseFloat(0.0001); bitcoinTransaction.sendTransaction({ from: from, to: to, privKeyWIF: privKeyWIF, btc: 0.00000547, network: "mainnet", fees: 3, }).catch((error) => { console.log(error); }).then((result)=> { console.log(result); }); console.log(balanceInBTC); }).catch((error) => { console.log(error); }); What i have to change to specify fixed fees for transaction. Is there any other API or node module that i can use for transfering BTC from one address to another using private key of address? You need to set the "fee" option... your code has it as "fees" ;) Title: Re: Tranfer BTC using API or using node modules Post by: DIGNIDAD on July 14, 2018, 07:39:48 PM hello, I have created bitcoin addresses dynamically using nodejs module. I have private key and address. we want to tranfer BTC received in those dynamically generated address we have private key for it. At present we are using below nodejs code to send BTC var bitcoinTransaction = require('bitcoin-transaction'); var to = "12zyHTgqfm3XT5K9afmaPjhcwvbAYuBBHk"; var from ="1DnqKVAPB9JUxQxuc6xe9jycyvhWhu7NzS"; var privKeyWIF = "XXXX-Privatekey-XXXXXXX"; bitcoinTransaction.getBalance(from, { network: "mainnet" }).then((balanceInBTC) => { var btcToSend=parseFloat(0.0001); bitcoinTransaction.sendTransaction({ from: from, to: to, privKeyWIF: privKeyWIF, btc: 0.00000547, network: "mainnet", fees: 3, }).catch((error) => { console.log(error); }).then((result)=> { console.log(result); }); console.log(balanceInBTC); }).catch((error) => { console.log(error); }); As we have done the transaction using this code it cost me fees as 206 satoshi per byte Here is the tx : https://www.[Suspicious link removed]/en/btc/tx/2d4639266d3af9416b1f022193a3587df501a678a794744dbf8f4fddcecc3564 What i have to change to specify fixed fees for transaction. Is there any other API or node module that i can use for transfering BTC from one address to another using private key of address? Hi, i think that changing the parameter fees could solve that, and if you are looking for other library i specially use bitcore-wallet-client there you can use the private key of address, that lets me specify the priority of transactions and many other specifications |