Tools
- A browser
- Bitcoin Gold core client
- (optional) An offline computer
Overall steps
- Get the transaction details (tx inputs) from a blockchain explorer
- Build a transaction to unlock your coins using the Bitcoin Gold core client
- Broadcast your transaction to the network
Basic knowledge
Bitcoin Gold transaction is made up of two parts: inputs and outputs. An input defines which wallet to consume and an output defines where to send the coin. A transaction can have multiple inputs and outputs.
Let"s see an example:
// inputs
[
{
"txid": "eca4b25e99484aa6907ab0e12486d4784c620730751587065beeb6a1d195114f",
"vout": 0,
"scriptPubKey": "a914daebff513795e6e8bb8c27d540afa5cee93c16d287",
"redeemScript": "5221032aa3765290ceb951c492fb37cc35dc7bf288faa63185b4fa96a4e8399342f2242103711df91db362c61536aaf8486548ff1686c6793bc6049afab79faed19b1a804052ae",
"amount": 0.21
},
{
"txid": "f22d9d88a414ee5ac2be4d5c58dbbf2d685bd739ec172db348bd4526a6a307eb",
"vout": 2,
"scriptPubKey": "a914225b3a7de5a8693c75e06cc81953741863c142d087",
"redeemScript": "522103711df91db362c61536aaf8486548ff1686c6793bc6049afab79faed19b1a804021032aa3765290ceb951c492fb37cc35dc7bf288faa63185b4fa96a4e8399342f22452ae",
"amount": 0.33
}
]
// outputs
{
"GWcPKN52GdMAd6rT5tAh5eEz8ZkfWKTTZB": 0.5,
"GL3GUp22D9QVscgpm24NYPUAEcGwVKKkBq": 0.039
}
This tx sends 0.54 BTG from two inputs to two addresses. The sum of the inputs is equal to the sum of the outputs, plus the miner fee:
0.21 + 0.33 (inputs) = 0.5 + 0.039 (outputs) + 0.001 (miner fee)
Transactions are chained by inputs and outputs. Each input consumes an output from a previous tx. So all you need to build a transaction is to find out the inputs that you want to spend from the blockchain, and write down your destination.
After you have created a correct tx, you can sign the tx by your private keys. Then the tx will be extended to include your signatures. And when all the signatures are attached, you are ready to send out the tx.
Walkthrough
Step 1: Get transaction details (inputs)
1.1: Get the your multis-sig address in BTG format
- Open https://btgwallet.online/#verify
- In “Verify” page, enter your redeem script and click “Submit”
- You will get the multi-sig address in BTG format (starts with “A”). Please save it somewhere for later use.
1.2: Get ScriptPubkey for your address
- Open https://chainquery.com/bitcoin-api/validateaddress
- Enter your multi-sig address in “Bitcoin Address” in Bitcoin format (starts with “3”) and click “Execute Command”
- You will find the “scriptPubKey” in the “Command Result”. Please save it for later use.
1.3: Get the inputs from Trezor’s Insight explorer
- Open
https://btg-bitcore2.trezor.io/api/addr/<YOUR ADDRESS>/utxo
in your browser. <YOUR ADDRESS>
is the address you got from last step.
(e.g. https://btg-bitcore2.trezor.io/api/addr/AbjRfhXSz1ywEK5iNj8cACuwZCU9dXCLei/utxo)
- You will see a list of inputs. The sum of “amount” should be your balance in this address. Please confirm it’s correct.
- Save all the inputs for later use.
Step 2: Build the raw transaction
2.1: Compose the input configuration
The inputs should be in the format shown below. Each input is surrounded by braces and separated by commas. Please duplicate if you have more than two inputs.
[
{
"txid": "<txid>",
"vout": "<vout>",
"scriptPubKey": "<script pubkey>",
"redeemScript": "<redeem script>",
"amount": <amount>
},
{
"txid": "<txid>",
"vout": "<vout>",
"scriptPubKey": "<script pubkey>",
"redeemScript": "<redeem script>",
"amount": <amount>
}
]
You can find <txid>
, <vout>
, and <amount>
from the inputs you got from Step 1.3 and <script pubkey>
from Step 1.1. <redeem script>
can be gotten from Coinbase. Note that <amount>
is measured in BTG (BTC) instead of satoshi.
Don’t forget to validate the format of the inputs. You can copy the final input info to https://jsonlint.com and click “Validate JSON”. Be aware of the comma and quotes. If everything is good, it will show a green “Valid JSON” message.
2.2 Compose the output configuration
Write down the output in the format shown below. The sum of the output amounts should be equal to the sum of the input amounts minus the miner fee.
{
"<address 1>": <amount 1>,
"<address 2>": <amount 2>,
"<address 3>": <amount 3>
}
Don’t forget to validate the JSON configuration. Now you should have the input and output configurations. The example in “Basic Knowledge” section can be a sample to compare.
2.2 Build a raw transaction
- Install Bitcoin Gold core node. You don’t need to wait for the full blockchain. There’s no problem to run it offline.
- If you run the GUI client, open the console. Otherwise you should use
bgold-cli
command line utility.
For GUI: Run this command with your own input and output configuirations:
createrawtransaction '<input configuration>' '<output configuiration>'
For command line: Run this command with your own input and output configuirations. Be aware of the escape:
bgold-cli createrawtransaction '''
<input configuration>
''' '''
<output configuration>
'''
Example:
bgold-cli createrawtransaction '''
[
{
"txid": "eca4b25e99484aa6907ab0e12486d4784c620730751587065beeb6a1d195114f",
"vout": 0,
"scriptPubKey": "a914daebff513795e6e8bb8c27d540afa5cee93c16d287",
"redeemScript": "5221032aa3765290ceb951c492fb37cc35dc7bf288faa63185b4fa96a4e8399342f2242103711df91db362c61536aaf8486548ff1686c6793bc6049afab79faed19b1a804052ae",
"amount": 0.21
},
{
"txid": "f22d9d88a414ee5ac2be4d5c58dbbf2d685bd739ec172db348bd4526a6a307eb",
"vout": 2,
"scriptPubKey": "a914225b3a7de5a8693c75e06cc81953741863c142d087",
"redeemScript": "522103711df91db362c61536aaf8486548ff1686c6793bc6049afab79faed19b1a804021032aa3765290ceb951c492fb37cc35dc7bf288faa63185b4fa96a4e8399342f22452ae",
"amount": 0.33
}
]''' '''{
"GWcPKN52GdMAd6rT5tAh5eEz8ZkfWKTTZB": 0.5,
"GL3GUp22D9QVscgpm24NYPUAEcGwVKKkBq": 0.039
}'''
Result:
02000000024f1195d1a1b6ee5b068715753007624c78d48624e1b07a90a64a48995eb2a4ec0000000000ffffffffeb07a3a62645bd48b32d17ec39d75b682dbfdb585c4dbec25aee14a4889d2df20200000000ffffffff0280f0fa02000000001976a9148c0a446a29c6f57df14fbb880bc90c3969ddae4688ac60823b00000000001976a9141815934900d3709ba7253e45bb7907205d75343788ac00000000
Then you will get a long hex string like the above one. It’s your raw transaction data. Please save it for later use.
2.3 Sign the transaction
[Warning] This is the only step that you need to use your private key. Please do it with great caution. It’s advisable to run it on an offline computer and destroy the key after this step.
For GUI: Run this command with the hex string you got from 2.2 and the input configuration:
signrawtransaction '<hex you got from 2.2>' '<input configuration>' '["<private key 1>", "<private key 2>"]'
For command line: Run this command with the hex string you got from 2.2 and the input configuration:
bgold-cli signrawtransaction '<hex you got from 2.2>' '''
<input configuration>''' '''
["<private key 1>", "<private key 2>"]
'''
Example:
bgold-cli signrawtransaction '02000000024f1195d1a1b6ee5b068715753007624c78d48624e1b07a90a64a48995eb2a4ec0000000000ffffffffeb07a3a62645bd48b32d17ec39d75b682dbfdb585c4dbec25aee14a4889d2df20200000000ffffffff0280f0fa02000000001976a9148c0a446a29c6f57df14fbb880bc90c3969ddae4688ac60823b00000000001976a9141815934900d3709ba7253e45bb7907205d75343788ac00000000' '''
[
{
"txid": "eca4b25e99484aa6907ab0e12486d4784c620730751587065beeb6a1d195114f",
"vout": 0,
"scriptPubKey": "a914daebff513795e6e8bb8c27d540afa5cee93c16d287",
"redeemScript": "5221032aa3765290ceb951c492fb37cc35dc7bf288faa63185b4fa96a4e8399342f2242103711df91db362c61536aaf8486548ff1686c6793bc6049afab79faed19b1a804052ae",
"amount": 0.21
},
{
"txid": "f22d9d88a414ee5ac2be4d5c58dbbf2d685bd739ec172db348bd4526a6a307eb",
"vout": 2,
"scriptPubKey": "a914225b3a7de5a8693c75e06cc81953741863c142d087",
"redeemScript": "522103711df91db362c61536aaf8486548ff1686c6793bc6049afab79faed19b1a804021032aa3765290ceb951c492fb37cc35dc7bf288faa63185b4fa96a4e8399342f22452ae",
"amount": 0.33
}
]''' '''
["L37v8XbTUgguPcz3C5TmWzMQvW4mcPkY4CMcQQCGCszneM4vsttK", "L3wCBNPCvR2s9DpovpXdcixZzFhu29BCESoE5BQNvj3t1PCQ4oL3"]
'''
Result:
{
"hex": "02000000024f1195d1a1b6ee5b068715753007624c78d48624e1b07a90a64a48995eb2a4ec00000000da00483045022100daa75f382405a14c29c35dc7be8ffaf9840fa91a2ae1a6766c9585d8d83a18420220032ae93e7aab45d36ffd360e17934b0ece7cf1daebb737900d9bfdb204cd947e4147304402206f4804ca7b39e75381318bcdb307e6bf308c4ef77d11deb4f19f6f29a8f326ac022040351d94f386520800388a1aab50ae051714585ca9e7ca91a58afdce461bdf7f41475221032aa3765290ceb951c492fb37cc35dc7bf288faa63185b4fa96a4e8399342f2242103711df91db362c61536aaf8486548ff1686c6793bc6049afab79faed19b1a804052aeffffffffeb07a3a62645bd48b32d17ec39d75b682dbfdb585c4dbec25aee14a4889d2df202000000da00473044022048ea6824940a7d9847e7613a81effead7ec03a065d1f9f44b43753c0bfeff92702205381a1fbe25e5c154250fceca28baf570f14615e4ce74cd29f3d6517deafbce4414830450221008d8b5b00e365a8f65e76d0b20e1fadee626de91729fc3d9f0e3b935e74bae6ec02202bdd7f098db7e4d241bb56f7eadfa2f714b4502afd08386eee4ee356154cb41d4147522103711df91db362c61536aaf8486548ff1686c6793bc6049afab79faed19b1a804021032aa3765290ceb951c492fb37cc35dc7bf288faa63185b4fa96a4e8399342f22452aeffffffff0280f0fa02000000001976a9148c0a446a29c6f57df14fbb880bc90c3969ddae4688ac60823b00000000001976a9141815934900d3709ba7253e45bb7907205d75343788ac00000000",
"complete": true
}
If everything is good, you should see the result. It should have "complete": true
. Otherwise the signing is failed. You should be able to find another very long hex string in the output as well. Please save it for broadcasting.
{
"hex" : "<final tx string>",
"complete" : true
}
Setp 3: Broadcast the transaction
Before doing anything, please check the input and output configuration (amount, target addresses, etc). Then check if the final transaction hex string is correct (it should only contain digital and a-z characters).
When everything is fine, you can open https://btg-bitcore2.trezor.io/tx/send, paste your raw transaction data there and press “Send transaction”.