update signrawtransaction
This commit is contained in:
parent
e91e02f2ce
commit
0424d5eb85
|
@ -131,7 +131,9 @@ class Commands:
|
||||||
|
|
||||||
def createmultisig(self, num, pubkeys):
|
def createmultisig(self, num, pubkeys):
|
||||||
assert isinstance(pubkeys, list)
|
assert isinstance(pubkeys, list)
|
||||||
return Transaction.multisig_script(pubkeys, num)
|
redeem_script = Transaction.multisig_script(pubkeys, num)
|
||||||
|
address = hash_160_to_bc_address(hash_160(redeem_script.decode('hex')), 5)
|
||||||
|
return {'address':address, 'redeemScript':redeem_script}
|
||||||
|
|
||||||
def freeze(self,addr):
|
def freeze(self,addr):
|
||||||
return self.wallet.freeze(addr)
|
return self.wallet.freeze(addr)
|
||||||
|
|
|
@ -366,15 +366,20 @@ class Wallet:
|
||||||
|
|
||||||
|
|
||||||
def signrawtransaction(self, tx, input_info, private_keys, password):
|
def signrawtransaction(self, tx, input_info, private_keys, password):
|
||||||
|
import deserialize
|
||||||
unspent_coins = self.get_unspent_coins()
|
unspent_coins = self.get_unspent_coins()
|
||||||
seed = self.decode_seed(password)
|
seed = self.decode_seed(password)
|
||||||
|
|
||||||
# convert private_keys to dict
|
# build a list of public/private keys
|
||||||
pk = {}
|
keypairs = {}
|
||||||
for sec in private_keys:
|
for sec in private_keys:
|
||||||
address = address_from_private_key(sec)
|
compressed = is_compressed(sec)
|
||||||
pk[address] = sec
|
pkey = regenerate_key(sec)
|
||||||
private_keys = pk
|
pubkey = GetPubKey(pkey.pubkey, compressed)
|
||||||
|
keypairs[ pubkey.encode('hex') ] = sec
|
||||||
|
|
||||||
|
# will be filled for each input
|
||||||
|
private_keys = {}
|
||||||
|
|
||||||
for txin in tx.inputs:
|
for txin in tx.inputs:
|
||||||
# convert to own format
|
# convert to own format
|
||||||
|
@ -396,26 +401,34 @@ class Wallet:
|
||||||
# if neither, we might want to get it from the server..
|
# if neither, we might want to get it from the server..
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# find the address:
|
# find the address and fill private_keys
|
||||||
if txin.get('KeyID'):
|
if txin.get('KeyID'):
|
||||||
account, name, sequence = txin.get('KeyID')
|
account, name, sequence = txin.get('KeyID')
|
||||||
if name != 'Electrum': continue
|
if name != 'BIP32': continue
|
||||||
sec = self.accounts[account].get_private_key(sequence, seed)
|
sec = self.accounts[account].get_private_key(sequence, seed)
|
||||||
addr = self.accounts[account].get_address(sequence)
|
addr = self.accounts[account].get_address(sequence)
|
||||||
txin['address'] = addr
|
txin['address'] = addr
|
||||||
private_keys[addr] = sec
|
private_keys[addr] = [sec]
|
||||||
|
|
||||||
elif txin.get("redeemScript"):
|
redeem_script = txin.get("redeemScript")
|
||||||
txin['address'] = hash_160_to_bc_address(hash_160(txin.get("redeemScript").decode('hex')), 5)
|
if redeem_script:
|
||||||
|
num, redeem_pubkeys = deserialize.parse_redeemScript(redeem_script)
|
||||||
|
addr = hash_160_to_bc_address(hash_160(redeem_script.decode('hex')), 5)
|
||||||
|
txin['address'] = addr
|
||||||
|
private_keys[addr] = []
|
||||||
|
for pubkey in redeem_pubkeys:
|
||||||
|
if pubkey in keypairs:
|
||||||
|
private_keys[addr].append( keypairs[pubkey] )
|
||||||
|
|
||||||
elif txin.get("raw_output_script"):
|
elif txin.get("raw_output_script"):
|
||||||
import deserialize
|
|
||||||
addr = deserialize.get_address_from_output_script(txin.get("raw_output_script").decode('hex'))
|
addr = deserialize.get_address_from_output_script(txin.get("raw_output_script").decode('hex'))
|
||||||
sec = self.get_private_key(addr, password)
|
sec = self.get_private_key(addr, password)
|
||||||
if sec:
|
if sec:
|
||||||
private_keys[addr] = sec
|
private_keys[addr] = [sec]
|
||||||
txin['address'] = addr
|
txin['address'] = addr
|
||||||
|
|
||||||
|
print txin
|
||||||
|
|
||||||
tx.sign( private_keys )
|
tx.sign( private_keys )
|
||||||
|
|
||||||
def sign_message(self, address, message, password):
|
def sign_message(self, address, message, password):
|
||||||
|
|
Loading…
Reference in New Issue