|
|
@ -91,6 +91,10 @@ options:\n --fee, -f: set transaction fee\n --fromaddr, -s: send from address |
|
|
|
'unfreeze':'', |
|
|
|
'prioritize':'', |
|
|
|
'unprioritize':'', |
|
|
|
'createmultisig':'similar to bitcoind\'s command', |
|
|
|
'createrawtransaction':'similar to bitcoind\'s command', |
|
|
|
'decoderawtransaction':'similar to bitcoind\'s command', |
|
|
|
'signrawtransaction':'similar to bitcoind\'s command', |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -103,10 +107,12 @@ offline_commands = [ 'password', 'mktx', 'signtx', |
|
|
|
'importprivkey', 'seed', |
|
|
|
'deseed','reseed', |
|
|
|
'freeze','unfreeze', |
|
|
|
'prioritize','unprioritize'] |
|
|
|
'prioritize','unprioritize', |
|
|
|
'createmultisig', 'createrawtransaction', 'decoderawtransaction', 'signrawtransaction' |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
protected_commands = ['payto', 'password', 'mktx', 'signtx', 'seed', 'importprivkey','signmessage' ] |
|
|
|
protected_commands = ['payto', 'password', 'mktx', 'signtx', 'seed', 'importprivkey','signmessage', 'signrawtransaction' ] |
|
|
|
|
|
|
|
# get password routine |
|
|
|
def prompt_password(prompt, confirm=True): |
|
|
@ -690,5 +696,53 @@ if __name__ == '__main__': |
|
|
|
print_msg(wallet.unprioritize(addr)) |
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'createmultisig': |
|
|
|
import ast |
|
|
|
from lib.bitcoin import * |
|
|
|
num = int(args[1]) |
|
|
|
pubkeys = ast.literal_eval(args[2]) |
|
|
|
assert isinstance(pubkeys,list) |
|
|
|
s = multisig_script(pubkeys, num) |
|
|
|
out = { "address": hash_160_to_bc_address(hash_160(s.decode('hex')), 5), "redeemScript":s } |
|
|
|
print_json(out) |
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'createrawtransaction': |
|
|
|
import ast |
|
|
|
inputs = ast.literal_eval(args[1]) |
|
|
|
outputs = ast.literal_eval(args[2]) |
|
|
|
inputs = map(lambda x: (None, None, x["txid"], x["vout"], None, None), inputs) |
|
|
|
outputs = map(lambda x: (x[0],int(x[1]*1e8)), outputs.items()) |
|
|
|
tx = raw_tx(inputs, outputs, for_sig = -1) # for_sig=-1 means do not sign |
|
|
|
print_msg( tx ) |
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'decoderawtransaction': |
|
|
|
print_json( bitcoin.deserialize(args[1]) ) |
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'signrawtransaction': |
|
|
|
d = bitcoin.deserialize(args[1]) |
|
|
|
txouts = args[2] if len(args)>2 else [] |
|
|
|
private_keys = args[3] if len(args)>3 else [] |
|
|
|
|
|
|
|
inputs = [] |
|
|
|
for x in d['inputs']: |
|
|
|
txid = x["prevout_hash"] |
|
|
|
nout = x["prevout_n"] |
|
|
|
tx = wallet.transactions.get(txid) |
|
|
|
txout = tx['outputs'][nout] |
|
|
|
addr = txout['address'] |
|
|
|
v = txout['value'] |
|
|
|
inputs.append( (addr, v, txid, nout, txout['raw_output_script'], [(None,None)] ) ) |
|
|
|
|
|
|
|
outputs = map(lambda x: (x['address'],x['value']), d['outputs']) |
|
|
|
print_error("inputs", inputs) |
|
|
|
print_error("outputs", outputs) |
|
|
|
|
|
|
|
tx = wallet.signed_tx( inputs, outputs, password ) |
|
|
|
print_msg(tx) |
|
|
|
|
|
|
|
|
|
|
|
if cmd not in offline_commands and not options.offline: |
|
|
|
synchronizer.stop() |
|
|
|