Bitcoin Forum
November 15, 2018, 11:48:02 AM *
News: Latest Bitcoin Core release: 0.17.0 [Torrent].
   Home   Help Search Login Register More  
Pages: [1]
Author Topic: Script to spend BCH from Armory Lockbox (2-of-3 Multisig)  (Read 208 times)
Offline Offline

Activity: 6
Merit: 0

View Profile
October 23, 2017, 09:44:22 PM

Here's a bash script I used to free some BCH from my Armory Lockbox. Feel free to use and enhance it!

Donations are appreciated!
BTC: 12YWVqdZqCrjJX4dAfKto47WSak93kB9mK
BCH: 14ZniiUi6Mu1ir6qZpvpMCbNDCnwYHcXsk

You need to fill the various variables in the script, specify the UTXO details (remove the "exit" line when you found those). This script will automatically send the signed transaction.

Make sure to leave some room between $ORIGAMOUNT (everything there is in the UTXO VOUT) and $AMOUNT (the amount you will get): the difference are fees for the miners.

Bitcoin ABC has to be running and referenced correctly in $CLI.

CLI=bitcoin-cli # Bitcoin ABC
# Get public keys by double clicking on lockbox in armory
# Find private keys in Armory:
# double click on wallet
# Find address in Unused Addresses - P2PKH (the first one in my case)
# Double click on address
# View Address Keys
# Use the Private Key (Base58) without spaces
COMPUTED_P2SH_ADDRESS=`$CLI createmultisig 2 "[\"$PUB1\", \"$PUB2\", \"$PUB3\"]" | jq -r ".address"`
echo "Computed address: $COMPUTED_P2SH_ADDRESS"
echo "Expected address: $P2SH_ADDRESS"
# Pick an unspent transaction which puts money into $P2SH_ADDRESS

$CLI getrawtransaction $UTXO_TXID 1
exit # Enter data below and remove this line
UTXO_VOUT=0 # .vout[n].n
UTXO_OUTPUT_SCRIPT="a914131357a7bddee4de25e96fbdfadd45276cb5bae987" #.vout[n].scriptPubKey.hex
ORIGAMOUNT=0.001 # .vout[n].value
AMOUNT=0.00095 # .vout[n].value (difference to $ORIGAMOUNT are fees!)

P2SH_REDEEM_SCRIPT=`$CLI createmultisig 2 "[\"$PUB1\", \"$PUB2\", \"$PUB3\"]" | jq -r ".redeemScript"`
RAW_TX=`$CLI createrawtransaction "[{\"txid\":\"$UTXO_TXID\",\"vout\":$UTXO_VOUT,\"redeemscript\":\"$P2SH_REDEEM_SCRIPT\"}]" "{\"$TARGETADDRESS\":$AMOUNT}"`
SIGNED_RAW_TX=`$CLI signrawtransaction $RAW_TX "[{\"txid\":\"$UTXO_TXID\",\"amount\":$ORIGAMOUNT,\"vout\":$UTXO_VOUT,\"scriptPubKey\":\"$UTXO_OUTPUT_SCRIPT\",\"redeemScript\":\"$P2SH_REDEEM_SCRIPT\"}]" "[\"$PRIVATE_KEY1\", \"$PRIVATE_KEY2\"]" | jq -r ".hex"`
$CLI sendrawtransaction $SIGNED_RAW_TX
Pages: [1]
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!