Created
January 29, 2017 22:38
-
-
Save davizalpe/538a41a021394009cba169fe1d4c38be to your computer and use it in GitHub Desktop.
Bitcoin client scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
./$BITCOIN_HOME/bin/bitcoin-cli -regtest generate 101 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -ne 1 ]; | |
then | |
echo "usage: $0 account"; | |
exit -1; | |
fi | |
bitcoin=$BITCOIN_HOME'/bitcoin-cli -regtest' | |
account=$1; | |
echo "List addresses from account:"; | |
$bitcoin getaddressesbyaccount $account; | |
echo ""; | |
echo "Received by address:"; | |
$bitcoin listreceivedbyaddress 1 false true|grep $account -C 2 | |
echo "Get unspent transactions" | |
addresses=`$bitcoin listreceivedbyaddress 1 false true|grep $account -C 1|grep address|cut -d' ' -f11|tr -d \",`; | |
#addresses=`echo $addresses | sed 's, *,,; s, *$,,'` | |
addressesjson=`echo $addresses | sed -r 's/ 2/","2/g'` | |
$bitcoin listunspent 1 99999 '''[ | |
"'$addressesjson'" | |
]''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based in https://bitcoin.org/en/developer-examples#p2sh-multisig | |
bitcoin=$BITCOIN_HOME"/bin/bitcoin-cli" | |
echo ""; | |
echo create 3 addresses | |
NEW_ADDRESS1=`$bitcoin getnewaddress` | |
echo $NEW_ADDRESS1 | |
NEW_ADDRESS2=`$bitcoin getnewaddress` | |
echo $NEW_ADDRESS2 | |
NEW_ADDRESS3=`$bitcoin getnewaddress` | |
echo $NEW_ADDRESS3 | |
echo ""; | |
echo validate address 1 | |
$bitcoin validateaddress $NEW_ADDRESS1 | |
echo "read public key 1" | |
read PUBLIC1 | |
echo validate address 2 | |
$bitcoin validateaddress $NEW_ADDRESS2 | |
echo "read public key 2" | |
read PUBLIC2 | |
echo validate address 3 | |
$bitcoin validateaddress $NEW_ADDRESS3 | |
echo "read public key 3" | |
read PUBLIC3 | |
echo ""; | |
echo create multisig | |
$bitcoin createmultisig 2 '''["'$PUBLIC1'", "'$PUBLIC2'", "'$PUBLIC3'"]''' | |
echo dump private keys | |
PRIV1=`$bitcoin dumpprivkey $NEW_ADDRESS1` | |
PRIV2=`$bitcoin dumpprivkey $NEW_ADDRESS2` | |
PRIV3=`$bitcoin dumpprivkey $NEW_ADDRESS3` | |
echo $PRIV1 | |
echo $PRIV2 | |
echo $PRIV3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -gt 0 ] && [ $1=="-regtest" ]; | |
then | |
$BITCOIN_HOME/bin/bitcoin-cli -regtest help | |
echo ""; | |
echo "Select a method: "; | |
read METHOD; | |
echo "\"$METHOD\"" | |
curl --user ${BITCOIN_RPC_USER}:${BITCOIN_RPC_PASS} --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": $METHOD, "params": [] }' -H 'content-type: text/plain;' https://localhost:8332/ | |
fi | |
curl --user ${BITCOIN_RPC_USER}:${BITCOIN_RPC_PASS} --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getaccountaddress", "params": ["user"] }' -H 'content-type: text/plain;' https://localhost:8332/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./$BITCOIN_HOME/bin/bitcoin-cli -regtest getaccountaddress 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./$BITCOIN_HOME/bin/bitcoin-cli -regtest listtransactions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
bitcoin=$BITCOIN_HOME"/bin/bitcoin-cli -regtest" | |
$bitcoin sendtoaddress $1 $2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
./$BITCOIN_HOME/bin/bitcoind \ | |
-regtest \ | |
-txindex \ | |
-daemon \ | |
-paytxfee=0.00005000 \ | |
-blocknotify="echo '%s' | nc localhost 4001" \ | |
-walletnotify="echo '%s' | nc localhost 4002" \ | |
-alertnotify="echo '%s' | nc localhost 4003" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment