support for multisig functions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from version import ELECTRUM_VERSION
|
||||
from util import format_satoshis, print_msg, print_error, set_verbosity
|
||||
from util import format_satoshis, print_msg, print_json, print_error, set_verbosity
|
||||
from i18n import set_language
|
||||
from wallet import WalletSynchronizer
|
||||
from wallet_factory import WalletFactory as Wallet
|
||||
|
||||
@@ -378,14 +378,33 @@ def raw_tx( inputs, outputs, for_sig = None ):
|
||||
s += var_int( len(tx_filter(script))/2 ) # script length
|
||||
s += script # script
|
||||
s += int_to_hex(0,4) # lock time
|
||||
if for_sig is not None: s += int_to_hex(1, 4) # hash type
|
||||
if for_sig is not None and for_sig != 1: s += int_to_hex(1, 4) # hash type
|
||||
return tx_filter(s)
|
||||
|
||||
|
||||
def multisig_script(public_keys):
|
||||
def deserialize(raw_tx):
|
||||
import deserialize
|
||||
vds = deserialize.BCDataStream()
|
||||
vds.write(raw_tx.decode('hex'))
|
||||
return deserialize.parse_Transaction(vds)
|
||||
|
||||
|
||||
def multisig_script(public_keys, num=None):
|
||||
# supports only "2 of 2", and "2 of 3" transactions
|
||||
n = len(public_keys)
|
||||
s = '52'
|
||||
|
||||
if num is None:
|
||||
num = n
|
||||
|
||||
assert num <= n and n <= 3 and n >= 2
|
||||
|
||||
if num==2:
|
||||
s = '52'
|
||||
elif num == 3:
|
||||
s = '53'
|
||||
else:
|
||||
raise
|
||||
|
||||
for k in public_keys:
|
||||
s += var_int(len(k)/2)
|
||||
s += k
|
||||
|
||||
@@ -22,6 +22,12 @@ def print_msg(*args):
|
||||
sys.stdout.write(" ".join(args) + "\n")
|
||||
sys.stdout.flush()
|
||||
|
||||
def print_json(obj):
|
||||
import json
|
||||
s = json.dumps(obj,sort_keys = True, indent = 4)
|
||||
sys.stdout.write(s + "\n")
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def check_windows_wallet_migration():
|
||||
if os.path.exists(os.path.join(os.environ["LOCALAPPDATA"], "Electrum")):
|
||||
|
||||
Reference in New Issue
Block a user