finales (OP)
Newbie
Offline
Activity: 13
Merit: 0
|
|
April 06, 2017, 05:09:09 PM |
|
Do you need to be running that code on a server that also acts as a Bitcoin Core Node in order to broadcast the transaction? Or am I misthinking how this works? Thanks!
|
|
|
|
dannon
Member
Offline
Activity: 70
Merit: 11
|
|
April 10, 2017, 12:03:02 PM |
|
You do not need to be running a node to create and sign transactions. You need to be running a node to have the data to put in the transaction or be able to get that data from somewhere else.
|
|
|
|
finales (OP)
Newbie
Offline
Activity: 13
Merit: 0
|
|
April 11, 2017, 06:45:58 PM |
|
What data are you referring to? Thanks
|
|
|
|
dannon
Member
Offline
Activity: 70
Merit: 11
|
|
April 12, 2017, 11:04:52 AM |
|
What data are you referring to? Thanks
Blockchain data. Information about previous transactions.
|
|
|
|
nemgun
|
|
April 12, 2017, 12:31:29 PM |
|
Do you need to be running that code on a server that also acts as a Bitcoin Core Node in order to broadcast the transaction? Or am I misthinking how this works? Thanks!
I suppose that you did this : var tx = new bitcoin.TransactionBuilder()
// Add the input (who is paying): // [previous transaction hash, index of the output to use] var txId = 'aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31' // tx.addInput(txId, 0)
// Add the output (who to pay to): // [payee's address, amount in satoshis] tx.addOutput("1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK", 15000)
// Initialize a private key using WIF var privateKeyWIF = 'L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy' var keyPair = bitcoin.ECPair.fromWIF(privateKeyWIF)
// Sign the first input with the new key tx.sign(0, keyPair);
/*-------------------------------------------Look here ---------------------------------------------*/ // Print transaction serialized as hex var hexTX = tx.build().toHex();
$.post('http://btc.blockr.io/api/v1/tx/push',{"hex":hexTX},function(data){ console.log(data); });
You just need to push it like in the example, but you should use $.Ajax instead of $.post because you iwll have more options to manage the transmission and secure it.
|
|
|
|
dannon
Member
Offline
Activity: 70
Merit: 11
|
|
April 14, 2017, 07:25:21 PM |
|
Do you need to be running that code on a server that also acts as a Bitcoin Core Node in order to broadcast the transaction? Or am I misthinking how this works? Thanks!
I suppose that you did this : var tx = new bitcoin.TransactionBuilder()
// Add the input (who is paying): // [previous transaction hash, index of the output to use] var txId = 'aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31' // tx.addInput(txId, 0)
// Add the output (who to pay to): // [payee's address, amount in satoshis] tx.addOutput("1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK", 15000)
// Initialize a private key using WIF var privateKeyWIF = 'L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy' var keyPair = bitcoin.ECPair.fromWIF(privateKeyWIF)
// Sign the first input with the new key tx.sign(0, keyPair);
/*-------------------------------------------Look here ---------------------------------------------*/ // Print transaction serialized as hex var hexTX = tx.build().toHex();
$.post('http://btc.blockr.io/api/v1/tx/push',{"hex":hexTX},function(data){ console.log(data); });
You just need to push it like in the example, but you should use $.Ajax instead of $.post because you iwll have more options to manage the transmission and secure it. You don't need jQuery. Just make an xmlhttprequest
|
|
|
|
nemgun
|
|
April 15, 2017, 10:18:55 AM Last edit: April 15, 2017, 11:16:20 AM by nemgun |
|
Do you need to be running that code on a server that also acts as a Bitcoin Core Node in order to broadcast the transaction? Or am I misthinking how this works? Thanks!
I suppose that you did this : var tx = new bitcoin.TransactionBuilder()
// Add the input (who is paying): // [previous transaction hash, index of the output to use] var txId = 'aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31' // tx.addInput(txId, 0)
// Add the output (who to pay to): // [payee's address, amount in satoshis] tx.addOutput("1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK", 15000)
// Initialize a private key using WIF var privateKeyWIF = 'L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy' var keyPair = bitcoin.ECPair.fromWIF(privateKeyWIF)
// Sign the first input with the new key tx.sign(0, keyPair);
/*-------------------------------------------Look here ---------------------------------------------*/ // Print transaction serialized as hex var hexTX = tx.build().toHex();
$.post('http://btc.blockr.io/api/v1/tx/push',{"hex":hexTX},function(data){ console.log(data); });
You just need to push it like in the example, but you should use $.Ajax instead of $.post because you iwll have more options to manage the transmission and secure it. You don't need jQuery. Just make an xmlhttprequest I said he "should" use jquery, because it is easier then using xhr, because is can be tricky, while using jQuery you can simply send Data, debug, customise the result, use promises or callbacks. While doing these using xhr will end with a 100 line of code, which is not the aim of developers i guess.
|
|
|
|
Kolder
|
|
April 15, 2017, 10:24:31 AM |
|
Anybody here can help me on installing bitcoinjs on my laptop. I'm using windows 10 OS. I succesfully installed the bitcoinjs exe file but i can't install the npm by using the command I hope somebody can help me.
|
|
|
|
nemgun
|
|
April 15, 2017, 10:30:27 AM |
|
Anybody here can help me on installing bitcoinjs on my laptop. I'm using windows 10 OS. I succesfully installed the bitcoinjs exe file but i can't install the npm by using the command I hope somebody can help me. yes, it is normall as you are asking npm to install npm, which is not really possible. use : npm install bitcoinjs-lib By the way, have you installed nodeJS ?
|
|
|
|
Kolder
|
|
April 15, 2017, 01:13:30 PM |
|
Anybody here can help me on installing bitcoinjs on my laptop. I'm using windows 10 OS. I succesfully installed the bitcoinjs exe file but i can't install the npm by using the command I hope somebody can help me. yes, it is normall as you are asking npm to install npm, which is not really possible. use : npm install bitcoinjs-lib By the way, have you installed nodeJS ? Yeah. I watch the tutorial on youtube regarding creating vanity address using bitcoinJS. In the tutorial. He used that code to install npm which is necessary to do your your suggested code. I saw that code on instruction on BitcoinJS but it has a $ symbol at the beginning. I try that code with $ sign at beginning but it didn't work out.
|
|
|
|
nemgun
|
|
April 15, 2017, 02:51:35 PM |
|
Anybody here can help me on installing bitcoinjs on my laptop. I'm using windows 10 OS. I succesfully installed the bitcoinjs exe file but i can't install the npm by using the command I hope somebody can help me. yes, it is normall as you are asking npm to install npm, which is not really possible. use : npm install bitcoinjs-lib By the way, have you installed nodeJS ? Yeah. I watch the tutorial on youtube regarding creating vanity address using bitcoinJS. In the tutorial. He used that code to install npm which is necessary to do your your suggested code. I saw that code on instruction on BitcoinJS but it has a $ symbol at the beginning. I try that code with $ sign at beginning but it didn't work out. ok, so, you are new to coding. $ is displayed in a terminal, these terminals are used bu Unix and MacOSX, so you don't have it in cmd, so i suppose you are using windows. When you have installed nodejs, create a directory and open a cmd inside the directory. then do then enter the informations, next to this do npm install --save bitcoinjs-lib jquery create a .txt file and rename it to main.js or index.js as you specified when npm init. Then open this file with a software like notepad2 or sublimetext, and add : var bitcoin = require('bitcoinjs-lib'); var $ = require('jquery'); // yes, we are in 2017, it had been solved
var tx = new bitcoin.TransactionBuilder();
// Add the input (who is paying): // [previous transaction hash, index of the output to use] var txId = 'aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31' ; tx.addInput(txId, 0);
// Add the output (who to pay to): // [payee's address, amount in satoshis] tx.addOutput("1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK", 15000);
// Initialize a private key using WIF var privateKeyWIF = 'L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy'; var keyPair = bitcoin.ECPair.fromWIF(privateKeyWIF);
// Sign the first input with the new key tx.sign(0, keyPair);
/*-------------------------------------------Look here ---------------------------------------------*/ // Print transaction serialized as hex var hexTX = tx.build().toHex();
$.post('http://btc.blockr.io/api/v1/tx/push',{"hex":hexTX},function(data){ console.log(data); });
And you are done.
|
|
|
|
finales (OP)
Newbie
Offline
Activity: 13
Merit: 0
|
|
April 16, 2017, 06:19:03 PM |
|
Is there a way to know on that same server when the transaction has been processed and added to the Blockchain? Thanks!
|
|
|
|
nemgun
|
|
April 17, 2017, 08:45:24 AM |
|
Is there a way to know on that same server when the transaction has been processed and added to the Blockchain? Thanks!
It is not related to the thread, but you can get these informations using APIs from block explorers, if you want to have a live feed of transaction confirmations, or reception, you can use blockcypher's websocket, subscribe and you will get all of these informations.
|
|
|
|
alexsamudra
|
|
April 17, 2017, 09:05:30 AM |
|
enough with the data that you've got it, do not need to sign the transaction. you simply enter the data and any further instructions ikutin into the transaction
|
|
|
|
|
iDice_io
|
|
April 27, 2017, 12:44:31 AM |
|
Do you need to be running that code on a server that also acts as a Bitcoin Core Node in order to broadcast the transaction? Or am I misthinking how this works? Thanks!
Create the transaction in BitcoinJS, which can then be broadcasted to a node (local, or not local). I believe Blockchain has a service for this.
|
|
|
|
Casy
Member
Offline
Activity: 149
Merit: 22
🔴🔵 FoxMixer.com 🔵🔴
|
|
April 27, 2017, 09:06:18 AM |
|
As you are new to coding, whatever you do, try it on the testnet first in order to prevent losing btc.
|
|
|
|
BluePoppy
Newbie
Offline
Activity: 57
Merit: 0
|
|
April 28, 2017, 07:36:48 AM |
|
Do you need to be running that code on a server that also acts as a Bitcoin Core Node in order to broadcast the transaction? Or am I misthinking how this works? Thanks!
Create the transaction in BitcoinJS, which can then be broadcasted to a node (local, or not local). I believe Blockchain has a service for this. Here's the link: https://blockchain.info/pushtxYup, BitcoinJS should be used here and then you can paste it manually. Or you can use Blockchain's API, which will be helpful if you're creating an application for users.
|
|
|
|
|