Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
richardkiss committed Aug 24, 2018
2 parents 6bdbe87 + 89db684 commit 256967d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
13 changes: 7 additions & 6 deletions recipes/multisig/1_create_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import os
import sys

from pycoin.key.BIP32Node import BIP32Node
from pycoin.encoding.hexbytes import b2h
from pycoin.ui.ui import address_for_p2s, script_for_multisig
from pycoin.symbols.btc import network

BIP32Node = network.extras.BIP32Node


def main():
Expand All @@ -19,7 +20,7 @@ def main():
hwif = f.readline().strip()

# turn the bip32 text into a BIP32Node object
BIP32_KEY = BIP32Node.from_hwif(hwif)
BIP32_KEY = network.ui.parse(hwif)

# create three sec_keys (these are public keys, streamed using the SEC format)

Expand All @@ -31,17 +32,17 @@ def main():

# create the 2-of-3 multisig script
# any 2 signatures can release the funds
pay_to_multisig_script = script_for_multisig(2, public_key_sec_list)
pay_to_multisig_script = network.ui._script_info.script_for_multisig(2, public_key_sec_list)

# create a "2-of-3" multisig address_for_multisig
the_address = address_for_p2s(pay_to_multisig_script)
the_address = network.ui.address_for_p2s(pay_to_multisig_script)

print("Here is your pay 2-of-3 address: %s" % the_address)

print("Here is the pay 2-of-3 script: %s" % b2h(pay_to_multisig_script))
print("The hex script should go into p2sh_lookup.hex")

base_dir = os.path.dirname(sys.argv[1])
base_dir = os.path.abspath(os.path.dirname(sys.argv[1]))
print("The three WIFs are written into %s as wif0, wif1 and wif2" % base_dir)
for i in range(3):
wif = BIP32_KEY.subkey_for_path("0/%d/0" % i).wif()
Expand Down
11 changes: 5 additions & 6 deletions recipes/multisig/2_create_coinbase_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import sys

from pycoin.key.validate import is_address_valid
from pycoin.tx.Tx import Tx, TxIn, TxOut
from pycoin.ui import script_for_address
from pycoin.symbols.btc import network
from pycoin.ui.validate import is_address_valid


def main():
Expand All @@ -21,9 +20,9 @@ def main():

print("creating coinbase transaction to %s" % address)

tx_in = TxIn.coinbase_tx_in(script=b'')
tx_out = TxOut(50*1e8, script_for_address(address))
tx = Tx(1, [tx_in], [tx_out])
tx_in = network.tx.TxIn.coinbase_tx_in(script=b'')
tx_out = network.tx.TxOut(50*1e8, network.ui.script_for_address(address))
tx = network.tx(1, [tx_in], [tx_out])
print("Here is the tx as hex:\n%s" % tx.as_hex())


Expand Down
8 changes: 4 additions & 4 deletions recipes/multisig/3_create_unsigned_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import sys

from pycoin.tx.Tx import Tx
from pycoin.tx.tx_utils import create_tx
from pycoin.key.validate import is_address_valid
from pycoin.coins.tx_utils import create_tx
from pycoin.ui.validate import is_address_valid
from pycoin.symbols.btc import network


def main():
Expand All @@ -23,7 +23,7 @@ def main():
tx_hex = f.readline().strip()

# get the spendable from the prior transaction
tx = Tx.from_hex(tx_hex)
tx = network.tx.from_hex(tx_hex)
tx_out_index = int(sys.argv[2])
spendable = tx.tx_outs_as_spendable()[tx_out_index]

Expand Down
8 changes: 4 additions & 4 deletions recipes/multisig/4_sign_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import sys

from pycoin.coins.tx_utils import sign_tx
from pycoin.encoding.hexbytes import h2b
from pycoin.key.validate import is_wif_valid
from pycoin.ui.validate import is_wif_valid
from pycoin.solve.utils import build_p2sh_lookup
from pycoin.tx.Tx import Tx
from pycoin.tx.tx_utils import sign_tx
from pycoin.symbols.btc import network


def main():
Expand All @@ -17,7 +17,7 @@ def main():
# get the tx
with open(sys.argv[1], "r") as f:
tx_hex = f.readline().strip()
tx = Tx.from_hex(tx_hex)
tx = network.tx.from_hex(tx_hex)

# get the WIF
with open(sys.argv[2], "r") as f:
Expand Down

0 comments on commit 256967d

Please sign in to comment.