# This simple wallet works with bitcoind and will only work with 2-of-3 multisigs # Using the python-bitcoinlib library # 如何分布三个私钥的存储 # 一个自己使用,一个存放在wallet provider, 一个放在最安全的地方,一般不用 # 如何来花这个multisig addr中的比特币? # 比如你想到taobao.com上去花比特币买东西,你这时用自己的私钥来 createrawTransaction,但是这时交易显示的花费是失败的, # 这时你将signed之后的原始交易发给第三方平台,这时你就让它用私钥来sign你sign过的transaction,这时会显示花费成功 import bitcoin from bitcoin.rpc import RawProxy bitcoin.SelectParams('testnet') p = RawProxy() #creates an object called p that allows for bitcoind calls money = p.getbalance() print(money) # YOU NEED AT LEAST TWO OF THE PRIVATE KEYS FROM PART ONE linked to your MULTI-SIG ADDRESS multisigprivkeyone = "cPw3fUfVnhZNNpg8mEnoNcbrk4VhhobDohZBcZdrS3pfP53ymhB2" multisigprivkeytwo = "cPpjLNPGgvwfCSUuXk1qExmBQB71piHxMUxmukzLr43m38VqsCHo" multisigprivkeythree = "cT2YurYhGWiShznfwzcsysf1a4koDhP369dtWiKBTyZV1HMTGLEk" ChangeAddress = "2NBwWtf4mQcmx1mR2tNSsuh21LsoPtbxA79" # Makes Sure to set your own personal Change Address SetTxFee = int(0.00005461 * 100000000) # ask your account, how much money you have unspent = p.listunspent( ) # Query wallet.dat file for unspent funds to see if we have multisigs to spend from print("Your Bitcoin-QT/d has", len(unspent), "unspent outputs") for i in range(0, len(unspent)):
from bitcoin.rpc import RawProxy p = RawProxy(service_port=18332) info = p.getbalance() print(info)