Skip to content

Commit

Permalink
Use network.script_info.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardkiss committed Aug 19, 2018
1 parent a682ffb commit fd3aa7f
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion pycoin/cmds/keychain.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def keychain(args, parser):

total_paths = 0

script_for_multisig = network.ui._script_info.script_for_multisig
script_for_multisig = network.script_info.script_for_multisig
for path in subpaths_for_path_range(subkey_paths):
if m:
secs = sorted([_.subkey_for_path(path).sec() for _ in keys])
Expand Down
2 changes: 1 addition & 1 deletion pycoin/networks/bitcoinish.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def f(public_pair):
yield ("address_segwit", address_segwit, "%s segwit address" % network_name)
yield ("%s_address_segwit" % network.symbol, address_segwit, "legacy")

p2sh_script = network.ui._script_info.script_for_p2pkh_wit(hash160_c)
p2sh_script = network.script_info.script_for_p2pkh_wit(hash160_c)
p2s_address = network.ui.address_for_p2s(p2sh_script)
if p2s_address:
yield ("p2sh_segwit", p2s_address, None)
Expand Down
6 changes: 3 additions & 3 deletions tests/address_for_script_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def make_tests_for_netcode(netcode):
network = network_for_netcode(netcode)

address_for_script = network.ui.address_for_script
script_for_p2pkh = network.ui._script_info.script_for_p2pkh
script_for_p2pk = network.ui._script_info.script_for_p2pk
script_for_nulldata = network.ui._script_info.script_for_nulldata
script_for_p2pkh = network.script_info.script_for_p2pkh
script_for_p2pk = network.script_info.script_for_p2pk
script_for_nulldata = network.script_info.script_for_nulldata

Tx = network.tx
Key = network.extras.Key
Expand Down
22 changes: 11 additions & 11 deletions tests/btc/segwit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
from pycoin.encoding.hexbytes import b2h, b2h_rev, h2b
from pycoin.satoshi.flags import SIGHASH_ALL, SIGHASH_SINGLE, SIGHASH_NONE, SIGHASH_ANYONECANPAY
from pycoin.solve.utils import build_hash160_lookup, build_p2sh_lookup
from pycoin.symbols.btc import network as BitcoinMainnet
from pycoin.symbols.btc import network


# BRAIN DAMAGE
Key = BitcoinMainnet.extras.Key
Tx = BitcoinMainnet.tx
TxOut = BitcoinMainnet.tx.TxOut
script_for_p2pkh = BitcoinMainnet.ui._script_info.script_for_p2pkh
script_for_p2pkh_wit = BitcoinMainnet.ui._script_info.script_for_p2pkh_wit
Key = network.extras.Key
Tx = network.tx
TxOut = network.tx.TxOut
script_for_p2pkh = network.script_info.script_for_p2pkh
script_for_p2pkh_wit = network.script_info.script_for_p2pkh_wit


class SegwitTest(unittest.TestCase):
Expand Down Expand Up @@ -49,8 +49,8 @@ def check_tx_can_be_signed(self, tx_u, tx_s, private_keys=[], p2sh_values=[]):
def test_segwit_ui(self):
# p2wpkh
address = 'bc1qqyykvamqq62n64t8gw09uw0cdgxjwwlw7mypam'
s = BitcoinMainnet.ui.script_for_address(address)
afs_address = BitcoinMainnet.ui.address_for_script(s)
s = network.ui.script_for_address(address)
afs_address = network.ui.address_for_script(s)
self.assertEqual(address, afs_address)

def test_segwit_create_tx(self):
Expand All @@ -68,8 +68,8 @@ def test_segwit_create_tx(self):
self.assertEqual(len(tx.txs_in[0].witness), 2)

s1 = script_for_p2pkh(key1.hash160())
address = BitcoinMainnet.ui.address_for_p2s_wit(s1)
spendable.script = BitcoinMainnet.ui.script_for_address(address)
address = network.ui.address_for_p2s_wit(s1)
spendable.script = network.ui.script_for_address(address)
tx = create_tx([spendable], [(key2.address(), coin_value)])
self.check_unsigned(tx)
sign_tx(tx, [key1.wif()], p2sh_lookup=build_p2sh_lookup([s1]))
Expand Down Expand Up @@ -148,7 +148,7 @@ def test_bip143_tx_1(self):
self.assertEqual(b2h(sc._hash_outputs(SIGHASH_ALL, 0)),
"863ef3e1a92afbfdb97f31ad0fc7683ee943e9abcf2501590ff8f6551f47e5e5")

script = BitcoinMainnet.ui._script_info.script_for_p2pkh(tx_s1.unspents[1].script[2:])
script = network.script_info.script_for_p2pkh(tx_s1.unspents[1].script[2:])
self.assertEqual(
b2h(sc._segwit_signature_preimage(script=script, tx_in_idx=1, hash_type=SIGHASH_ALL)),
"0100000096b827c8483d4e9b96712b6713a7b68d6e8003a781feba36c31143470b4efd"
Expand Down
2 changes: 1 addition & 1 deletion tests/multisig_individual_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


Key = network.extras.Key
script_for_multisig = network.ui._script_info.script_for_multisig
script_for_multisig = network.script_info.script_for_multisig
Tx = network.tx


Expand Down
8 changes: 4 additions & 4 deletions tests/pay_to_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@


# BRAIN DAMAGE
script_info_for_script = network.ui._script_info.info_for_script
script_for_multisig = network.ui._script_info.script_for_multisig
script_for_nulldata = network.ui._script_info.script_for_nulldata
script_for_nulldata_push = network.ui._script_info.script_for_nulldata_push
script_info_for_script = network.script_info.info_for_script
script_for_multisig = network.script_info.script_for_multisig
script_for_nulldata = network.script_info.script_for_nulldata
script_for_nulldata_push = network.script_info.script_for_nulldata_push
Tx = network.tx


Expand Down
2 changes: 1 addition & 1 deletion tests/sign_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# BRAIN DAMAGE
address_for_p2s = network.ui.address_for_p2s
script_for_address = network.ui.script_for_address
script_for_multisig = network.ui._script_info.script_for_multisig
script_for_multisig = network.script_info.script_for_multisig

Spendable = network.tx.Spendable
Tx = network.tx
Expand Down
4 changes: 2 additions & 2 deletions tests/solver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

address_for_p2s = network.ui.address_for_p2s
script_for_address = network.ui.script_for_address
script_for_multisig = network.ui._script_info.script_for_multisig
script_for_p2pk = network.ui._script_info.script_for_p2pk
script_for_multisig = network.script_info.script_for_multisig
script_for_p2pk = network.script_info.script_for_p2pk

# BRAIN DAMAGE
Key = network.extras.Key
Expand Down
18 changes: 9 additions & 9 deletions tests/validation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,32 +239,32 @@ def _make_tx(self, input_script, other_scripts=[]):
return tx

def test_validate_p2pkh(self):
us_1 = network.ui._script_info.script_for_p2pkh(self._key.hash160())
us_1 = network.script_info.script_for_p2pkh(self._key.hash160())
tx = self._make_tx(us_1)
tx.check_solution(0)

def test_validate_p2s_of_p2pkh(self):
us_1 = network.ui._script_info.script_for_p2pkh(self._key.hash160())
us_2 = network.ui._script_info.script_for_p2s(us_1)
us_1 = network.script_info.script_for_p2pkh(self._key.hash160())
us_2 = network.script_info.script_for_p2s(us_1)
tx = self._make_tx(us_2, [us_1])
tx.check_solution(0)

def test_validate_p2pkh_wit(self):
us_1 = network.ui._script_info.script_for_p2pkh_wit(self._key.hash160())
us_1 = network.script_info.script_for_p2pkh_wit(self._key.hash160())
tx = self._make_tx(us_1)
tx.check_solution(0)

def test_validate_p2s_wit_of_p2pkh(self):
us_1 = network.ui._script_info.script_for_p2pkh_wit(self._key.hash160())
us_2 = network.ui._script_info.script_for_p2s(us_1)
us_1 = network.script_info.script_for_p2pkh_wit(self._key.hash160())
us_2 = network.script_info.script_for_p2s(us_1)
tx = self._make_tx(us_2, [us_1])
self.assertEqual(tx.id(), "1e5d967a3778bfa4e0d90f35f59530e8033a36bd7fd1d9e617c504054b89bd3a")
tx.check_solution(0)

def test_validate_p2s_of_p2s_wit_of_p2pkh(self):
us_1 = network.ui._script_info.script_for_p2pkh(self._key.hash160())
us_2 = network.ui._script_info.script_for_p2s_wit(us_1)
us_3 = network.ui._script_info.script_for_p2s(us_2)
us_1 = network.script_info.script_for_p2pkh(self._key.hash160())
us_2 = network.script_info.script_for_p2s_wit(us_1)
us_3 = network.script_info.script_for_p2s(us_2)
tx = self._make_tx(us_3, [us_1, us_2])
self.assertEqual(tx.id(), "54a518b82b464744951531270c1bcec133c515fcdbe9d70c6141e067a62ff640")
tx.check_solution(0)
Expand Down
2 changes: 1 addition & 1 deletion tests/who_signed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
UI = network.ui
address_for_p2s = UI.address_for_p2s
script_for_address = UI.script_for_address
script_for_multisig = UI._script_info.script_for_multisig
script_for_multisig = network.script_info.script_for_multisig
Key = UI._key_class
Tx = network.tx

Expand Down

0 comments on commit fd3aa7f

Please sign in to comment.