mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-28 16:01:30 +00:00
fix privkey serialization in commands
This commit is contained in:
parent
5873fe8eaf
commit
26becedfb2
1 changed files with 9 additions and 9 deletions
|
@ -216,16 +216,15 @@ class Commands:
|
||||||
prevout_hash, prevout_n = txin['output'].split(':')
|
prevout_hash, prevout_n = txin['output'].split(':')
|
||||||
txin['prevout_n'] = int(prevout_n)
|
txin['prevout_n'] = int(prevout_n)
|
||||||
txin['prevout_hash'] = prevout_hash
|
txin['prevout_hash'] = prevout_hash
|
||||||
if txin.get('redeemPubkey'):
|
sec = txin.get('privkey')
|
||||||
pubkey = txin['redeemPubkey']
|
if sec:
|
||||||
txin['type'] = 'p2pkh'
|
txin_type, privkey, compressed = bitcoin.deserialize_privkey(sec)
|
||||||
|
pubkey = bitcoin.public_key_from_private_key(privkey, compressed)
|
||||||
|
keypairs[pubkey] = privkey, compressed
|
||||||
|
txin['type'] = txin_type
|
||||||
txin['x_pubkeys'] = [pubkey]
|
txin['x_pubkeys'] = [pubkey]
|
||||||
txin['signatures'] = [None]
|
txin['signatures'] = [None]
|
||||||
txin['num_sig'] = 1
|
txin['num_sig'] = 1
|
||||||
if txin.get('privkey'):
|
|
||||||
keypairs[pubkey] = txin['privkey']
|
|
||||||
elif txin.get('redeemScript'):
|
|
||||||
raise BaseException('Not implemented')
|
|
||||||
|
|
||||||
outputs = [(TYPE_ADDRESS, x['address'], int(x['value'])) for x in outputs]
|
outputs = [(TYPE_ADDRESS, x['address'], int(x['value'])) for x in outputs]
|
||||||
tx = Transaction.from_io(inputs, outputs, locktime=locktime)
|
tx = Transaction.from_io(inputs, outputs, locktime=locktime)
|
||||||
|
@ -237,10 +236,11 @@ class Commands:
|
||||||
"""Sign a transaction. The wallet keys will be used unless a private key is provided."""
|
"""Sign a transaction. The wallet keys will be used unless a private key is provided."""
|
||||||
tx = Transaction(tx)
|
tx = Transaction(tx)
|
||||||
if privkey:
|
if privkey:
|
||||||
pubkey = bitcoin.public_key_from_private_key(privkey)
|
txin_type, privkey2, compressed = bitcoin.deserialize_privkey(privkey)
|
||||||
|
pubkey = bitcoin.public_key_from_private_key(privkey2, compressed)
|
||||||
h160 = bitcoin.hash_160(bfh(pubkey))
|
h160 = bitcoin.hash_160(bfh(pubkey))
|
||||||
x_pubkey = 'fd' + bh2u(b'\x00' + h160)
|
x_pubkey = 'fd' + bh2u(b'\x00' + h160)
|
||||||
tx.sign({x_pubkey:privkey})
|
tx.sign({x_pubkey:(privkey2, compressed)})
|
||||||
else:
|
else:
|
||||||
self.wallet.sign_transaction(tx, password)
|
self.wallet.sign_transaction(tx, password)
|
||||||
return tx.as_dict()
|
return tx.as_dict()
|
||||||
|
|
Loading…
Add table
Reference in a new issue