1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-11-26 01:50:42 +00:00

Edited appdx-bitcore.asciidoc with Atlas code editor

This commit is contained in:
nadams 2017-04-21 11:50:53 -07:00
parent f5a59f9dd7
commit 093a6069a8

View File

@ -41,27 +41,22 @@ $ NODE_PATH=$(npm list -g | head -1)/node_modules node
Creating a new bitcoin address with associated private key
====
----
> bitcore = require('bitcore-lib')
> privateKey = new bitcore.PrivateKey()
> address = privateKey.toAddress().toString()
----
====
Creating a Hierarchical Deterministic private key and address
====
----
> hdPrivateKey = bitcore.HDPrivateKey()
> hdPublicKey = bitcore.HDPublicKey(hdPrivateKey)
> hdAddress = new bitcore.Address(hdPublicKey.publicKey).toString()
----
====
Creating and signing a transaction from a UTXO
====
----
> utxo = {
txId: transaction id containing an unspent output,
@ -78,12 +73,10 @@ Creating and signing a transaction from a UTXO
.enableRBF()
.sign(privateKeyOfUtxo)
----
====
Replace the last transaction in the mempool (replace-by-fee)
====
---
----
> rbfTx = new Transaction()
.from(utxo)
.to(address, 35000)
@ -92,8 +85,7 @@ Replace the last transaction in the mempool (replace-by-fee)
.sign(privateKeyOfUtxo);
> tx.serialize();
> rbfTx.serialize();
---
====
----
Broadcasting a transaction to the Bitcoin network
Note: Broadcast valid transactions only, refer to https://bitnodes.21.co/nodes for peer hosts
@ -103,8 +95,7 @@ Note: Broadcast valid transactions only, refer to https://bitnodes.21.co/nodes f
3. In order to replace-by-fee, the peer must support bitcoind option "mempoolreplace" and have it set to "1"
4. Run the file: node broadcast.js
====
---
----
var p2p = require('bitcore-p2p');
var bitcore = require('bitcore-lib');
var tx = new bitcore.Transaction('output from serialize function');
@ -126,5 +117,4 @@ peer.on('ready', function() {
}, 2000);
});
peer.connect();
---
====
----