mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.4 KiB
2.4 KiB
send-transaction
The purpose of this exercise is to create a simple Bitcoin transaction locally using the command line. As we use new tools this exercise is guided.
Instructions
-
Install a Bitcoin node. There are two solutions :
export bitcoinCoreVersion="24.0.1"
wget -q "https://bitcoincore.org/bin/bitcoin-core-$bitcoinCoreVersion/bitcoin-$bitcoinCoreVersion-x86_64-linux-gnu.tar.gz"
tar xzf "bitcoin-$bitcoinCoreVersion-x86_64-linux-gnu.tar.gz"
sudo mv bitcoin-$bitcoinCoreVersion/bin/* /usr/local/bin
rm -rf bitcoin-$bitcoinCoreVersion/
rm "bitcoin-$bitcoinCoreVersion-x86_64-linux-gnu.tar.gz"
- Launch Bitcoin core daemon on regtest network. You can do so with the following command assuming the executable is in your shell's path.
$ bitcoind -chain=regtest -daemon -fallbackfee=0.00000003
$
- Create manually a wallet and two addresses on Bitcoin regtest. You may do this by running the following commands
$ bitcoin-cli -regtest createwallet "testwallet"
...
$ bitcoin-cli -regtest getnewaddress
...
$ bitcoin-cli -regtest getnewaddress
...
$
- Generate 101 blocks to get fresh bitcoins. You need 101 blocks as the Bitcoin you receive from mining are locked for 100 blocks. You may use the following command:
$ bitcoin-cli -regtest generatetoaddress 101 <your address>
...
$
- Send a transaction of 2 bitcoins to the second address.
$ bitcoin-cli -regtest sendtoaddress <the second address> 2
...
$
- List the last transactions
$ bitcoin-cli -regtest listtransactions
...
$
- Create a JS file
send-transaction.js
with a variabletxid
that will store the hash of your transaction. The variabletxid
needs to be importable from an external file! Below an example on how you should export your variable.
exports.txid = ...
Congrats for your first Bitcoin transaction!
Notions
- Bitcoin core node bitcoin.org
- Bitcoin for developers introduction
- A Linux image with developer tools cryptotux.org