trezor multisig: build xpub from pubkey
This commit is contained in:
@@ -714,6 +714,14 @@ def bip32_root(seed, testnet=False):
|
|||||||
return EncodeBase58Check(xprv), EncodeBase58Check(xpub)
|
return EncodeBase58Check(xprv), EncodeBase58Check(xpub)
|
||||||
|
|
||||||
|
|
||||||
|
def xpub_from_pubkey(cK, testnet=False):
|
||||||
|
header_pub, header_priv = _get_headers(testnet)
|
||||||
|
assert cK[0] in ['\x02','\x03']
|
||||||
|
master_c = chr(0)*32
|
||||||
|
xpub = (header_pub + "00" + "00000000" + "00000000").decode("hex") + master_c + cK
|
||||||
|
return EncodeBase58Check(xpub)
|
||||||
|
|
||||||
|
|
||||||
def bip32_private_derivation(xprv, branch, sequence, testnet=False):
|
def bip32_private_derivation(xprv, branch, sequence, testnet=False):
|
||||||
assert sequence.startswith(branch)
|
assert sequence.startswith(branch)
|
||||||
if branch == sequence:
|
if branch == sequence:
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ from PyQt4.Qt import QMessageBox, QDialog, QVBoxLayout, QLabel, QThread, SIGNAL,
|
|||||||
import PyQt4.QtCore as QtCore
|
import PyQt4.QtCore as QtCore
|
||||||
|
|
||||||
import electrum
|
import electrum
|
||||||
|
from electrum import bitcoin
|
||||||
|
|
||||||
from electrum.account import BIP32_Account
|
from electrum.account import BIP32_Account
|
||||||
from electrum.bitcoin import EncodeBase58Check, public_key_to_bc_address, bc_address_to_hash_160
|
from electrum.bitcoin import EncodeBase58Check, public_key_to_bc_address, bc_address_to_hash_160, xpub_from_pubkey
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.plugins import BasePlugin, hook, always_hook, run_hook
|
from electrum.plugins import BasePlugin, hook, always_hook, run_hook
|
||||||
from electrum.transaction import Transaction, deserialize, is_extended_pubkey, x_to_xpub
|
from electrum.transaction import Transaction, deserialize, is_extended_pubkey, x_to_xpub
|
||||||
@@ -245,8 +247,6 @@ class Plugin(BasePlugin):
|
|||||||
def tx_inputs(self, tx, for_sig=False):
|
def tx_inputs(self, tx, for_sig=False):
|
||||||
inputs = []
|
inputs = []
|
||||||
for txin in tx.inputs:
|
for txin in tx.inputs:
|
||||||
print txin
|
|
||||||
|
|
||||||
txinputtype = types.TxInputType()
|
txinputtype = types.TxInputType()
|
||||||
if txin.get('is_coinbase'):
|
if txin.get('is_coinbase'):
|
||||||
prev_hash = "\0"*32
|
prev_hash = "\0"*32
|
||||||
@@ -261,13 +261,17 @@ class Plugin(BasePlugin):
|
|||||||
txinputtype.address_n.extend(xpub_n + s)
|
txinputtype.address_n.extend(xpub_n + s)
|
||||||
else:
|
else:
|
||||||
def f(x_pubkey):
|
def f(x_pubkey):
|
||||||
xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
|
if is_extended_pubkey(x_pubkey):
|
||||||
|
xpub, s = BIP32_Account.parse_xpubkey(x_pubkey)
|
||||||
|
else:
|
||||||
|
xpub = xpub_from_pubkey(x_pubkey.decode('hex'))
|
||||||
|
s = []
|
||||||
node = ckd_public.deserialize(xpub)
|
node = ckd_public.deserialize(xpub)
|
||||||
return types.HDNodePathType(node=node, address_n=s)
|
return types.HDNodePathType(node=node, address_n=s)
|
||||||
pubkeys = map(f, x_pubkeys)
|
pubkeys = map(f, x_pubkeys)
|
||||||
multisig = types.MultisigRedeemScriptType(
|
multisig = types.MultisigRedeemScriptType(
|
||||||
pubkeys=pubkeys,
|
pubkeys=pubkeys,
|
||||||
signatures=map(lambda x: x if x else '', txin.get('signatures')),
|
signatures=map(lambda x: x.decode('hex') if x else '', txin.get('signatures')),
|
||||||
m=txin.get('num_sig'),
|
m=txin.get('num_sig'),
|
||||||
)
|
)
|
||||||
txinputtype = types.TxInputType(
|
txinputtype = types.TxInputType(
|
||||||
|
|||||||
Reference in New Issue
Block a user