mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-11 07:50:57 +00:00
core/sign_tx: Updates based on code review.
This commit is contained in:
parent
c2a0f83558
commit
c1effcc374
@ -27,16 +27,21 @@ if False:
|
|||||||
async def sign_tx(ctx: wire.Context, msg: SignTx, keychain: seed.Keychain) -> TxRequest:
|
async def sign_tx(ctx: wire.Context, msg: SignTx, keychain: seed.Keychain) -> TxRequest:
|
||||||
coin_name = msg.coin_name if msg.coin_name is not None else "Bitcoin"
|
coin_name = msg.coin_name if msg.coin_name is not None else "Bitcoin"
|
||||||
coin = coins.by_name(coin_name)
|
coin = coins.by_name(coin_name)
|
||||||
if not utils.BITCOIN_ONLY and coin.decred:
|
try:
|
||||||
coinsig = decred.Decred() # type: bitcoin.Bitcoin
|
if not utils.BITCOIN_ONLY and coin.decred:
|
||||||
elif not utils.BITCOIN_ONLY and coin.overwintered:
|
signer = decred.Decred(msg, keychain, coin).signer()
|
||||||
coinsig = zcash.Overwintered()
|
elif not utils.BITCOIN_ONLY and coin.overwintered:
|
||||||
elif not utils.BITCOIN_ONLY and coin_name not in ("Bitcoin", "Regtest", "Testnet"):
|
signer = zcash.Overwintered(msg, keychain, coin).signer()
|
||||||
coinsig = bitcoinlike.Bitcoinlike()
|
elif not utils.BITCOIN_ONLY and coin_name not in (
|
||||||
else:
|
"Bitcoin",
|
||||||
coinsig = bitcoin.Bitcoin()
|
"Regtest",
|
||||||
|
"Testnet",
|
||||||
signer = coinsig.signer(msg, keychain, coin)
|
):
|
||||||
|
signer = bitcoinlike.Bitcoinlike(msg, keychain, coin).signer()
|
||||||
|
else:
|
||||||
|
signer = bitcoin.Bitcoin(msg, keychain, coin).signer()
|
||||||
|
except common.SigningError as e:
|
||||||
|
raise wire.Error(*e.args)
|
||||||
|
|
||||||
res = None # type: Union[TxAck, bool]
|
res = None # type: Union[TxAck, bool]
|
||||||
while True:
|
while True:
|
||||||
|
@ -17,6 +17,7 @@ from apps.wallet.sign_tx.scripts import (
|
|||||||
if False:
|
if False:
|
||||||
from typing import List
|
from typing import List
|
||||||
from trezor.crypto import bip32
|
from trezor.crypto import bip32
|
||||||
|
from trezor.messages.TxInputType import EnumTypeInputScriptType
|
||||||
|
|
||||||
# supported witness version for bech32 addresses
|
# supported witness version for bech32 addresses
|
||||||
_BECH32_WITVER = const(0x00)
|
_BECH32_WITVER = const(0x00)
|
||||||
@ -201,7 +202,10 @@ def address_short(coin: CoinInfo, address: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def validate_full_path(
|
def validate_full_path(
|
||||||
path: list, coin: CoinInfo, script_type: int, validate_script_type: bool = True
|
path: list,
|
||||||
|
coin: CoinInfo,
|
||||||
|
script_type: EnumTypeInputScriptType,
|
||||||
|
validate_script_type: bool = True,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
Validates derivation path to fit Bitcoin-like coins. We mostly use
|
Validates derivation path to fit Bitcoin-like coins. We mostly use
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import gc
|
import gc
|
||||||
from micropython import const
|
from micropython import const
|
||||||
|
|
||||||
from trezor import utils
|
|
||||||
from trezor.crypto.hashlib import sha256
|
from trezor.crypto.hashlib import sha256
|
||||||
from trezor.messages import FailureType, InputScriptType
|
from trezor.messages import FailureType, InputScriptType
|
||||||
from trezor.messages.SignTx import SignTx
|
from trezor.messages.SignTx import SignTx
|
||||||
@ -12,6 +11,7 @@ from trezor.messages.TxOutputType import TxOutputType
|
|||||||
from trezor.messages.TxRequest import TxRequest
|
from trezor.messages.TxRequest import TxRequest
|
||||||
from trezor.messages.TxRequestDetailsType import TxRequestDetailsType
|
from trezor.messages.TxRequestDetailsType import TxRequestDetailsType
|
||||||
from trezor.messages.TxRequestSerializedType import TxRequestSerializedType
|
from trezor.messages.TxRequestSerializedType import TxRequestSerializedType
|
||||||
|
from trezor.utils import HashWriter, ensure
|
||||||
|
|
||||||
from apps.common import coininfo, seed
|
from apps.common import coininfo, seed
|
||||||
from apps.wallet.sign_tx import (
|
from apps.wallet.sign_tx import (
|
||||||
@ -28,7 +28,10 @@ from apps.wallet.sign_tx.common import SigningError, ecdsa_sign
|
|||||||
from apps.wallet.sign_tx.matchcheck import MultisigFingerprintChecker, WalletPathChecker
|
from apps.wallet.sign_tx.matchcheck import MultisigFingerprintChecker, WalletPathChecker
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
from typing import Dict, Union
|
from typing import Set, Union
|
||||||
|
|
||||||
|
# Default signature hash type in Bitcoin, which signs the entire transaction except scripts.
|
||||||
|
_SIGHASH_ALL = const(0x01)
|
||||||
|
|
||||||
# the chain id used for change
|
# the chain id used for change
|
||||||
_BIP32_CHANGE_CHAIN = const(1)
|
_BIP32_CHANGE_CHAIN = const(1)
|
||||||
@ -49,11 +52,7 @@ _MAX_SERIALIZED_CHUNK_SIZE = const(2048)
|
|||||||
|
|
||||||
|
|
||||||
class Bitcoin:
|
class Bitcoin:
|
||||||
async def signer(
|
async def signer(self) -> None:
|
||||||
self, tx: SignTx, keychain: seed.Keychain, coin: coininfo.CoinInfo
|
|
||||||
) -> None:
|
|
||||||
self.initialize(tx, keychain, coin)
|
|
||||||
|
|
||||||
progress.init(self.tx.inputs_count, self.tx.outputs_count)
|
progress.init(self.tx.inputs_count, self.tx.outputs_count)
|
||||||
|
|
||||||
# Add inputs to hash143 and h_confirmed and compute the sum of input amounts.
|
# Add inputs to hash143 and h_confirmed and compute the sum of input amounts.
|
||||||
@ -64,7 +63,7 @@ class Bitcoin:
|
|||||||
await self.step2_confirm_outputs()
|
await self.step2_confirm_outputs()
|
||||||
|
|
||||||
# Check fee, confirm lock_time and total.
|
# Check fee, confirm lock_time and total.
|
||||||
await self.step3_confirm_tran()
|
await self.step3_confirm_tx()
|
||||||
|
|
||||||
# Check that inputs are unchanged. Serialize inputs and sign the non-segwit ones.
|
# Check that inputs are unchanged. Serialize inputs and sign the non-segwit ones.
|
||||||
await self.step4_serialize_inputs()
|
await self.step4_serialize_inputs()
|
||||||
@ -78,11 +77,11 @@ class Bitcoin:
|
|||||||
# Write footer and send remaining data.
|
# Write footer and send remaining data.
|
||||||
await self.step7_finish()
|
await self.step7_finish()
|
||||||
|
|
||||||
def initialize(
|
def __init__(
|
||||||
self, tx: SignTx, keychain: seed.Keychain, coin: coininfo.CoinInfo
|
self, tx: SignTx, keychain: seed.Keychain, coin: coininfo.CoinInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
self.coin = coin
|
self.coin = coin
|
||||||
self.tx = helpers.sanitize_sign_tx(tx, self.coin)
|
self.tx = helpers.sanitize_sign_tx(tx, coin)
|
||||||
self.keychain = keychain
|
self.keychain = keychain
|
||||||
|
|
||||||
# checksum of multisig inputs, used to validate change-output
|
# checksum of multisig inputs, used to validate change-output
|
||||||
@ -91,8 +90,8 @@ class Bitcoin:
|
|||||||
# common prefix of input paths, used to validate change-output
|
# common prefix of input paths, used to validate change-output
|
||||||
self.wallet_path = WalletPathChecker()
|
self.wallet_path = WalletPathChecker()
|
||||||
|
|
||||||
# dict of booleans stating if input is segwit
|
# set of indices of inputs which are segwit
|
||||||
self.segwit = {} # type: Dict[int, bool]
|
self.segwit = set() # type: Set[int]
|
||||||
|
|
||||||
# amounts
|
# amounts
|
||||||
self.total_in = 0 # sum of input amounts
|
self.total_in = 0 # sum of input amounts
|
||||||
@ -119,8 +118,8 @@ class Bitcoin:
|
|||||||
def create_hash143(self) -> segwit_bip143.Bip143:
|
def create_hash143(self) -> segwit_bip143.Bip143:
|
||||||
return segwit_bip143.Bip143()
|
return segwit_bip143.Bip143()
|
||||||
|
|
||||||
def create_hash_writer(self) -> utils.HashWriter:
|
def create_hash_writer(self) -> HashWriter:
|
||||||
return utils.HashWriter(sha256())
|
return HashWriter(sha256())
|
||||||
|
|
||||||
async def step1_process_inputs(self) -> None:
|
async def step1_process_inputs(self) -> None:
|
||||||
for i in range(self.tx.inputs_count):
|
for i in range(self.tx.inputs_count):
|
||||||
@ -140,7 +139,7 @@ class Bitcoin:
|
|||||||
self.weight.add_output(txo_bin.script_pubkey)
|
self.weight.add_output(txo_bin.script_pubkey)
|
||||||
await self.confirm_output(i, txo, txo_bin)
|
await self.confirm_output(i, txo, txo_bin)
|
||||||
|
|
||||||
async def step3_confirm_tran(self) -> None:
|
async def step3_confirm_tx(self) -> None:
|
||||||
fee = self.total_in - self.total_out
|
fee = self.total_in - self.total_out
|
||||||
|
|
||||||
if fee < 0:
|
if fee < 0:
|
||||||
@ -161,10 +160,10 @@ class Bitcoin:
|
|||||||
raise SigningError(FailureType.ActionCancelled, "Total cancelled")
|
raise SigningError(FailureType.ActionCancelled, "Total cancelled")
|
||||||
|
|
||||||
async def step4_serialize_inputs(self) -> None:
|
async def step4_serialize_inputs(self) -> None:
|
||||||
self.write_sign_tx_header(self.serialized_tx, True in self.segwit.values())
|
self.write_sign_tx_header(self.serialized_tx, bool(self.segwit))
|
||||||
for i in range(self.tx.inputs_count):
|
for i in range(self.tx.inputs_count):
|
||||||
progress.advance()
|
progress.advance()
|
||||||
if self.segwit[i]:
|
if i in self.segwit:
|
||||||
await self.serialize_segwit_input(i)
|
await self.serialize_segwit_input(i)
|
||||||
else:
|
else:
|
||||||
await self.sign_nonsegwit_input(i)
|
await self.sign_nonsegwit_input(i)
|
||||||
@ -176,10 +175,10 @@ class Bitcoin:
|
|||||||
await self.serialize_output(i)
|
await self.serialize_output(i)
|
||||||
|
|
||||||
async def step6_sign_segwit_inputs(self) -> None:
|
async def step6_sign_segwit_inputs(self) -> None:
|
||||||
any_segwit = True in self.segwit.values()
|
any_segwit = bool(self.segwit)
|
||||||
for i in range(self.tx.inputs_count):
|
for i in range(self.tx.inputs_count):
|
||||||
progress.advance()
|
progress.advance()
|
||||||
if self.segwit[i]:
|
if i in self.segwit:
|
||||||
await self.sign_segwit_input(i)
|
await self.sign_segwit_input(i)
|
||||||
elif any_segwit:
|
elif any_segwit:
|
||||||
# add empty witness for non-segwit inputs
|
# add empty witness for non-segwit inputs
|
||||||
@ -193,17 +192,15 @@ class Bitcoin:
|
|||||||
self.wallet_path.add_input(txi)
|
self.wallet_path.add_input(txi)
|
||||||
self.multisig_fingerprint.add_input(txi)
|
self.multisig_fingerprint.add_input(txi)
|
||||||
writers.write_tx_input_check(self.h_confirmed, txi)
|
writers.write_tx_input_check(self.h_confirmed, txi)
|
||||||
self.hash143.add_prevouts(txi) # all inputs are included (non-segwit as well)
|
self.hash143.add_input(txi) # all inputs are included (non-segwit as well)
|
||||||
self.hash143.add_sequence(txi)
|
|
||||||
|
|
||||||
if not addresses.validate_full_path(txi.address_n, self.coin, txi.script_type):
|
if not addresses.validate_full_path(txi.address_n, self.coin, txi.script_type):
|
||||||
await helpers.confirm_foreign_address(txi.address_n)
|
await helpers.confirm_foreign_address(txi.address_n)
|
||||||
|
|
||||||
if input_is_segwit(txi):
|
if input_is_segwit(txi):
|
||||||
self.segwit[i] = True
|
self.segwit.add(i)
|
||||||
await self.process_segwit_input(i, txi)
|
await self.process_segwit_input(i, txi)
|
||||||
elif input_is_nonsegwit(txi):
|
elif input_is_nonsegwit(txi):
|
||||||
self.segwit[i] = False
|
|
||||||
await self.process_nonsegwit_input(i, txi)
|
await self.process_nonsegwit_input(i, txi)
|
||||||
else:
|
else:
|
||||||
raise SigningError(FailureType.DataError, "Wrong input script type")
|
raise SigningError(FailureType.DataError, "Wrong input script type")
|
||||||
@ -277,6 +274,7 @@ class Bitcoin:
|
|||||||
)
|
)
|
||||||
|
|
||||||
signature = ecdsa_sign(node, hash143_hash)
|
signature = ecdsa_sign(node, hash143_hash)
|
||||||
|
self.set_serialized_signature(i, signature)
|
||||||
if txi.multisig:
|
if txi.multisig:
|
||||||
# find out place of our signature based on the pubkey
|
# find out place of our signature based on the pubkey
|
||||||
signature_index = multisig.multisig_pubkey_index(txi.multisig, key_sign_pub)
|
signature_index = multisig.multisig_pubkey_index(txi.multisig, key_sign_pub)
|
||||||
@ -290,9 +288,6 @@ class Bitcoin:
|
|||||||
scripts.witness_p2wpkh(signature, key_sign_pub, self.get_hash_type())
|
scripts.witness_p2wpkh(signature, key_sign_pub, self.get_hash_type())
|
||||||
)
|
)
|
||||||
|
|
||||||
self.tx_req.serialized.signature_index = i
|
|
||||||
self.tx_req.serialized.signature = signature
|
|
||||||
|
|
||||||
async def sign_nonsegwit_input(self, i_sign: int) -> None:
|
async def sign_nonsegwit_input(self, i_sign: int) -> None:
|
||||||
# hash of what we are signing with this input
|
# hash of what we are signing with this input
|
||||||
h_sign = self.create_hash_writer()
|
h_sign = self.create_hash_writer()
|
||||||
@ -366,9 +361,7 @@ class Bitcoin:
|
|||||||
txi_sign, key_sign_pub, signature
|
txi_sign, key_sign_pub, signature
|
||||||
)
|
)
|
||||||
self.write_tx_input(self.serialized_tx, txi_sign)
|
self.write_tx_input(self.serialized_tx, txi_sign)
|
||||||
|
self.set_serialized_signature(i_sign, signature)
|
||||||
self.tx_req.serialized.signature_index = i_sign
|
|
||||||
self.tx_req.serialized.signature = signature
|
|
||||||
|
|
||||||
async def serialize_output(self, i: int) -> None:
|
async def serialize_output(self, i: int) -> None:
|
||||||
# STAGE_REQUEST_5_OUTPUT
|
# STAGE_REQUEST_5_OUTPUT
|
||||||
@ -432,8 +425,7 @@ class Bitcoin:
|
|||||||
# ===
|
# ===
|
||||||
|
|
||||||
def get_hash_type(self) -> int:
|
def get_hash_type(self) -> int:
|
||||||
SIGHASH_ALL = const(0x01)
|
return _SIGHASH_ALL
|
||||||
return SIGHASH_ALL
|
|
||||||
|
|
||||||
def write_tx_input(self, w: writers.Writer, txi: TxInputType) -> None:
|
def write_tx_input(self, w: writers.Writer, txi: TxInputType) -> None:
|
||||||
writers.write_tx_input(w, txi)
|
writers.write_tx_input(w, txi)
|
||||||
@ -458,6 +450,13 @@ class Bitcoin:
|
|||||||
) -> None:
|
) -> None:
|
||||||
writers.write_uint32(w, tx.lock_time)
|
writers.write_uint32(w, tx.lock_time)
|
||||||
|
|
||||||
|
def set_serialized_signature(self, index: int, signature: bytes) -> None:
|
||||||
|
# Only one signature per TxRequest can be serialized.
|
||||||
|
ensure(self.tx_req.serialized.signature is None)
|
||||||
|
|
||||||
|
self.tx_req.serialized.signature_index = index
|
||||||
|
self.tx_req.serialized.signature = signature
|
||||||
|
|
||||||
# TX Outputs
|
# TX Outputs
|
||||||
# ===
|
# ===
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ from apps.wallet.sign_tx.common import SigningError, ecdsa_sign
|
|||||||
if False:
|
if False:
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
_SIGHASH_FORKID = const(0x40)
|
||||||
|
|
||||||
|
|
||||||
class Bitcoinlike(Bitcoin):
|
class Bitcoinlike(Bitcoin):
|
||||||
async def process_segwit_input(self, i: int, txi: TxInputType) -> None:
|
async def process_segwit_input(self, i: int, txi: TxInputType) -> None:
|
||||||
@ -29,7 +31,6 @@ class Bitcoinlike(Bitcoin):
|
|||||||
async def process_bip143_input(self, i: int, txi: TxInputType) -> None:
|
async def process_bip143_input(self, i: int, txi: TxInputType) -> None:
|
||||||
if not txi.amount:
|
if not txi.amount:
|
||||||
raise SigningError(FailureType.DataError, "Expected input with amount")
|
raise SigningError(FailureType.DataError, "Expected input with amount")
|
||||||
self.segwit[i] = False
|
|
||||||
self.bip143_in += txi.amount
|
self.bip143_in += txi.amount
|
||||||
self.total_in += txi.amount
|
self.total_in += txi.amount
|
||||||
|
|
||||||
@ -77,8 +78,7 @@ class Bitcoinlike(Bitcoin):
|
|||||||
txi_sign, key_sign_pub, signature
|
txi_sign, key_sign_pub, signature
|
||||||
)
|
)
|
||||||
writers.write_tx_input(self.serialized_tx, txi_sign)
|
writers.write_tx_input(self.serialized_tx, txi_sign)
|
||||||
self.tx_req.serialized.signature_index = i_sign
|
self.set_serialized_signature(i_sign, signature)
|
||||||
self.tx_req.serialized.signature = signature
|
|
||||||
|
|
||||||
def on_negative_fee(self) -> None:
|
def on_negative_fee(self) -> None:
|
||||||
# some coins require negative fees for reward TX
|
# some coins require negative fees for reward TX
|
||||||
@ -86,10 +86,9 @@ class Bitcoinlike(Bitcoin):
|
|||||||
super().on_negative_fee()
|
super().on_negative_fee()
|
||||||
|
|
||||||
def get_hash_type(self) -> int:
|
def get_hash_type(self) -> int:
|
||||||
SIGHASH_FORKID = const(0x40)
|
|
||||||
hashtype = super().get_hash_type()
|
hashtype = super().get_hash_type()
|
||||||
if self.coin.fork_id is not None:
|
if self.coin.fork_id is not None:
|
||||||
hashtype |= (self.coin.fork_id << 8) | SIGHASH_FORKID
|
hashtype |= (self.coin.fork_id << 8) | _SIGHASH_FORKID
|
||||||
return hashtype
|
return hashtype
|
||||||
|
|
||||||
def write_tx_header(
|
def write_tx_header(
|
||||||
|
@ -38,12 +38,9 @@ class DecredPrefixHasher(Bip143):
|
|||||||
writers.write_uint32(self.h_prefix, tx.version | DECRED_SERIALIZE_NO_WITNESS)
|
writers.write_uint32(self.h_prefix, tx.version | DECRED_SERIALIZE_NO_WITNESS)
|
||||||
writers.write_varint(self.h_prefix, tx.inputs_count)
|
writers.write_varint(self.h_prefix, tx.inputs_count)
|
||||||
|
|
||||||
def add_prevouts(self, txi: TxInputType) -> None:
|
def add_input(self, txi: TxInputType) -> None:
|
||||||
writers.write_tx_input_decred(self.h_prefix, txi)
|
writers.write_tx_input_decred(self.h_prefix, txi)
|
||||||
|
|
||||||
def add_sequence(self, txi: TxInputType) -> None:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def add_output_count(self, tx: SignTx) -> None:
|
def add_output_count(self, tx: SignTx) -> None:
|
||||||
writers.write_varint(self.h_prefix, tx.outputs_count)
|
writers.write_varint(self.h_prefix, tx.outputs_count)
|
||||||
|
|
||||||
@ -59,11 +56,11 @@ class DecredPrefixHasher(Bip143):
|
|||||||
|
|
||||||
|
|
||||||
class Decred(Bitcoin):
|
class Decred(Bitcoin):
|
||||||
def initialize(
|
def __init__(
|
||||||
self, tx: SignTx, keychain: seed.Keychain, coin: coininfo.CoinInfo
|
self, tx: SignTx, keychain: seed.Keychain, coin: coininfo.CoinInfo
|
||||||
) -> None:
|
) -> None:
|
||||||
ensure(coin.decred)
|
ensure(coin.decred)
|
||||||
super().initialize(tx, keychain, coin)
|
super().__init__(tx, keychain, coin)
|
||||||
|
|
||||||
def create_hash143(self) -> Bip143:
|
def create_hash143(self) -> Bip143:
|
||||||
return DecredPrefixHasher(self.tx) # pseudo BIP-0143 prefix hashing
|
return DecredPrefixHasher(self.tx) # pseudo BIP-0143 prefix hashing
|
||||||
@ -161,9 +158,7 @@ class Decred(Bitcoin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
writers.write_tx_input_decred_witness(self.serialized_tx, txi_sign)
|
writers.write_tx_input_decred_witness(self.serialized_tx, txi_sign)
|
||||||
|
self.set_serialized_signature(i_sign, signature)
|
||||||
self.tx_req.serialized.signature_index = i_sign
|
|
||||||
self.tx_req.serialized.signature = signature
|
|
||||||
|
|
||||||
async def step5_serialize_outputs(self) -> None:
|
async def step5_serialize_outputs(self) -> None:
|
||||||
pass
|
pass
|
||||||
@ -171,9 +166,6 @@ class Decred(Bitcoin):
|
|||||||
async def step6_sign_segwit_inputs(self) -> None:
|
async def step6_sign_segwit_inputs(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def write_sign_tx_footer(self, w: writers.Writer) -> None:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def check_prevtx_output(self, txo_bin: TxOutputBinType) -> None:
|
def check_prevtx_output(self, txo_bin: TxOutputBinType) -> None:
|
||||||
if (
|
if (
|
||||||
txo_bin.decred_script_version is not None
|
txo_bin.decred_script_version is not None
|
||||||
@ -196,6 +188,9 @@ class Decred(Bitcoin):
|
|||||||
) -> None:
|
) -> None:
|
||||||
writers.write_uint32(w, tx.version | DECRED_SERIALIZE_NO_WITNESS)
|
writers.write_uint32(w, tx.version | DECRED_SERIALIZE_NO_WITNESS)
|
||||||
|
|
||||||
|
def write_sign_tx_footer(self, w: writers.Writer) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
async def write_prev_tx_footer(
|
async def write_prev_tx_footer(
|
||||||
self, w: writers.Writer, tx: TransactionType, prev_hash: bytes
|
self, w: writers.Writer, tx: TransactionType, prev_hash: bytes
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -120,11 +120,8 @@ def confirm_nondefault_locktime(lock_time: int) -> Awaitable[Any]: # type: igno
|
|||||||
def request_tx_meta(tx_req: TxRequest, coin: CoinInfo, tx_hash: bytes = None) -> Awaitable[Any]: # type: ignore
|
def request_tx_meta(tx_req: TxRequest, coin: CoinInfo, tx_hash: bytes = None) -> Awaitable[Any]: # type: ignore
|
||||||
tx_req.request_type = TXMETA
|
tx_req.request_type = TXMETA
|
||||||
tx_req.details.tx_hash = tx_hash
|
tx_req.details.tx_hash = tx_hash
|
||||||
tx_req.details.request_index = None
|
|
||||||
ack = yield tx_req
|
ack = yield tx_req
|
||||||
tx_req.serialized.signature = None
|
_clear_tx_request(tx_req)
|
||||||
tx_req.serialized.signature_index = None
|
|
||||||
tx_req.serialized.serialized_tx[:] = bytes()
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
return sanitize_tx_meta(ack.tx, coin)
|
return sanitize_tx_meta(ack.tx, coin)
|
||||||
|
|
||||||
@ -136,13 +133,8 @@ def request_tx_extra_data( # type: ignore
|
|||||||
tx_req.details.extra_data_offset = offset
|
tx_req.details.extra_data_offset = offset
|
||||||
tx_req.details.extra_data_len = size
|
tx_req.details.extra_data_len = size
|
||||||
tx_req.details.tx_hash = tx_hash
|
tx_req.details.tx_hash = tx_hash
|
||||||
tx_req.details.request_index = None
|
|
||||||
ack = yield tx_req
|
ack = yield tx_req
|
||||||
tx_req.serialized.signature = None
|
_clear_tx_request(tx_req)
|
||||||
tx_req.serialized.signature_index = None
|
|
||||||
tx_req.serialized.serialized_tx[:] = bytes()
|
|
||||||
tx_req.details.extra_data_offset = None
|
|
||||||
tx_req.details.extra_data_len = None
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
return ack.tx.extra_data
|
return ack.tx.extra_data
|
||||||
|
|
||||||
@ -152,9 +144,7 @@ def request_tx_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes =
|
|||||||
tx_req.details.request_index = i
|
tx_req.details.request_index = i
|
||||||
tx_req.details.tx_hash = tx_hash
|
tx_req.details.tx_hash = tx_hash
|
||||||
ack = yield tx_req
|
ack = yield tx_req
|
||||||
tx_req.serialized.signature = None
|
_clear_tx_request(tx_req)
|
||||||
tx_req.serialized.signature_index = None
|
|
||||||
tx_req.serialized.serialized_tx[:] = bytes()
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
return sanitize_tx_input(ack.tx, coin)
|
return sanitize_tx_input(ack.tx, coin)
|
||||||
|
|
||||||
@ -164,9 +154,7 @@ def request_tx_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes
|
|||||||
tx_req.details.request_index = i
|
tx_req.details.request_index = i
|
||||||
tx_req.details.tx_hash = tx_hash
|
tx_req.details.tx_hash = tx_hash
|
||||||
ack = yield tx_req
|
ack = yield tx_req
|
||||||
tx_req.serialized.signature = None
|
_clear_tx_request(tx_req)
|
||||||
tx_req.serialized.signature_index = None
|
|
||||||
tx_req.serialized.serialized_tx[:] = bytes()
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
if tx_hash is None:
|
if tx_hash is None:
|
||||||
return sanitize_tx_output(ack.tx, coin)
|
return sanitize_tx_output(ack.tx, coin)
|
||||||
@ -176,12 +164,20 @@ def request_tx_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes
|
|||||||
|
|
||||||
def request_tx_finish(tx_req: TxRequest) -> Awaitable[Any]: # type: ignore
|
def request_tx_finish(tx_req: TxRequest) -> Awaitable[Any]: # type: ignore
|
||||||
tx_req.request_type = TXFINISHED
|
tx_req.request_type = TXFINISHED
|
||||||
tx_req.details = None
|
|
||||||
yield tx_req
|
yield tx_req
|
||||||
|
_clear_tx_request(tx_req)
|
||||||
|
gc.collect()
|
||||||
|
|
||||||
|
|
||||||
|
def _clear_tx_request(tx_req: TxRequest) -> None:
|
||||||
|
tx_req.request_type = None
|
||||||
|
tx_req.details.request_index = None
|
||||||
|
tx_req.details.tx_hash = None
|
||||||
|
tx_req.details.extra_data_len = None
|
||||||
|
tx_req.details.extra_data_offset = None
|
||||||
tx_req.serialized.signature = None
|
tx_req.serialized.signature = None
|
||||||
tx_req.serialized.signature_index = None
|
tx_req.serialized.signature_index = None
|
||||||
tx_req.serialized.serialized_tx[:] = bytes()
|
tx_req.serialized.serialized_tx[:] = bytes()
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
|
|
||||||
# Data sanitizers
|
# Data sanitizers
|
||||||
|
@ -30,11 +30,9 @@ class Bip143:
|
|||||||
self.h_sequence = HashWriter(sha256())
|
self.h_sequence = HashWriter(sha256())
|
||||||
self.h_outputs = HashWriter(sha256())
|
self.h_outputs = HashWriter(sha256())
|
||||||
|
|
||||||
def add_prevouts(self, txi: TxInputType) -> None:
|
def add_input(self, txi: TxInputType) -> None:
|
||||||
write_bytes_reversed(self.h_prevouts, txi.prev_hash, TX_HASH_SIZE)
|
write_bytes_reversed(self.h_prevouts, txi.prev_hash, TX_HASH_SIZE)
|
||||||
write_uint32(self.h_prevouts, txi.prev_index)
|
write_uint32(self.h_prevouts, txi.prev_index)
|
||||||
|
|
||||||
def add_sequence(self, txi: TxInputType) -> None:
|
|
||||||
write_uint32(self.h_sequence, txi.sequence)
|
write_uint32(self.h_sequence, txi.sequence)
|
||||||
|
|
||||||
def add_output_count(self, tx: SignTx) -> None:
|
def add_output_count(self, tx: SignTx) -> None:
|
||||||
|
@ -180,9 +180,9 @@ class Zip243(Zip143):
|
|||||||
|
|
||||||
|
|
||||||
class Overwintered(Bitcoinlike):
|
class Overwintered(Bitcoinlike):
|
||||||
def initialize(self, tx: SignTx, keychain: Keychain, coin: CoinInfo) -> None:
|
def __init__(self, tx: SignTx, keychain: Keychain, coin: CoinInfo) -> None:
|
||||||
ensure(coin.overwintered)
|
ensure(coin.overwintered)
|
||||||
super().initialize(tx, keychain, coin)
|
super().__init__(tx, keychain, coin)
|
||||||
|
|
||||||
def create_hash143(self) -> Bip143:
|
def create_hash143(self) -> Bip143:
|
||||||
if self.tx.version == 3:
|
if self.tx.version == 3:
|
||||||
|
@ -45,16 +45,16 @@ class TestSegwitBip143NativeP2WPKH(unittest.TestCase):
|
|||||||
def test_prevouts(self):
|
def test_prevouts(self):
|
||||||
|
|
||||||
bip143 = Bip143()
|
bip143 = Bip143()
|
||||||
bip143.add_prevouts(self.inp1)
|
bip143.add_input(self.inp1)
|
||||||
bip143.add_prevouts(self.inp2)
|
bip143.add_input(self.inp2)
|
||||||
coin = coins.by_name(self.tx.coin_name)
|
coin = coins.by_name(self.tx.coin_name)
|
||||||
self.assertEqual(hexlify(bip143.get_prevouts_hash(coin)), b'96b827c8483d4e9b96712b6713a7b68d6e8003a781feba36c31143470b4efd37')
|
self.assertEqual(hexlify(bip143.get_prevouts_hash(coin)), b'96b827c8483d4e9b96712b6713a7b68d6e8003a781feba36c31143470b4efd37')
|
||||||
|
|
||||||
def test_sequence(self):
|
def test_sequence(self):
|
||||||
|
|
||||||
bip143 = Bip143()
|
bip143 = Bip143()
|
||||||
bip143.add_sequence(self.inp1)
|
bip143.add_input(self.inp1)
|
||||||
bip143.add_sequence(self.inp2)
|
bip143.add_input(self.inp2)
|
||||||
coin = coins.by_name(self.tx.coin_name)
|
coin = coins.by_name(self.tx.coin_name)
|
||||||
self.assertEqual(hexlify(bip143.get_sequence_hash(coin)), b'52b0a642eea2fb7ae638c36f6252b6750293dbe574a806984b8e4d8548339a3b')
|
self.assertEqual(hexlify(bip143.get_sequence_hash(coin)), b'52b0a642eea2fb7ae638c36f6252b6750293dbe574a806984b8e4d8548339a3b')
|
||||||
|
|
||||||
@ -80,10 +80,8 @@ class TestSegwitBip143NativeP2WPKH(unittest.TestCase):
|
|||||||
coin = coins.by_name(self.tx.coin_name)
|
coin = coins.by_name(self.tx.coin_name)
|
||||||
|
|
||||||
bip143 = Bip143()
|
bip143 = Bip143()
|
||||||
bip143.add_prevouts(self.inp1)
|
bip143.add_input(self.inp1)
|
||||||
bip143.add_prevouts(self.inp2)
|
bip143.add_input(self.inp2)
|
||||||
bip143.add_sequence(self.inp1)
|
|
||||||
bip143.add_sequence(self.inp2)
|
|
||||||
|
|
||||||
for txo in [self.out1, self.out2]:
|
for txo in [self.out1, self.out2]:
|
||||||
txo_bin = TxOutputBinType()
|
txo_bin = TxOutputBinType()
|
||||||
|
@ -37,14 +37,14 @@ class TestSegwitBip143(unittest.TestCase):
|
|||||||
def test_bip143_prevouts(self):
|
def test_bip143_prevouts(self):
|
||||||
|
|
||||||
bip143 = Bip143()
|
bip143 = Bip143()
|
||||||
bip143.add_prevouts(self.inp1)
|
bip143.add_input(self.inp1)
|
||||||
coin = coins.by_name(self.tx.coin_name)
|
coin = coins.by_name(self.tx.coin_name)
|
||||||
self.assertEqual(hexlify(bip143.get_prevouts_hash(coin)), b'b0287b4a252ac05af83d2dcef00ba313af78a3e9c329afa216eb3aa2a7b4613a')
|
self.assertEqual(hexlify(bip143.get_prevouts_hash(coin)), b'b0287b4a252ac05af83d2dcef00ba313af78a3e9c329afa216eb3aa2a7b4613a')
|
||||||
|
|
||||||
def test_bip143_sequence(self):
|
def test_bip143_sequence(self):
|
||||||
|
|
||||||
bip143 = Bip143()
|
bip143 = Bip143()
|
||||||
bip143.add_sequence(self.inp1)
|
bip143.add_input(self.inp1)
|
||||||
coin = coins.by_name(self.tx.coin_name)
|
coin = coins.by_name(self.tx.coin_name)
|
||||||
self.assertEqual(hexlify(bip143.get_sequence_hash(coin)), b'18606b350cd8bf565266bc352f0caddcf01e8fa789dd8a15386327cf8cabe198')
|
self.assertEqual(hexlify(bip143.get_sequence_hash(coin)), b'18606b350cd8bf565266bc352f0caddcf01e8fa789dd8a15386327cf8cabe198')
|
||||||
|
|
||||||
@ -70,8 +70,7 @@ class TestSegwitBip143(unittest.TestCase):
|
|||||||
coin = coins.by_name(self.tx.coin_name)
|
coin = coins.by_name(self.tx.coin_name)
|
||||||
|
|
||||||
bip143 = Bip143()
|
bip143 = Bip143()
|
||||||
bip143.add_prevouts(self.inp1)
|
bip143.add_input(self.inp1)
|
||||||
bip143.add_sequence(self.inp1)
|
|
||||||
for txo in [self.out1, self.out2]:
|
for txo in [self.out1, self.out2]:
|
||||||
txo_bin = TxOutputBinType()
|
txo_bin = TxOutputBinType()
|
||||||
txo_bin.amount = txo.amount
|
txo_bin.amount = txo.amount
|
||||||
|
@ -29,7 +29,6 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase):
|
|||||||
def test_send_native_p2wpkh(self):
|
def test_send_native_p2wpkh(self):
|
||||||
|
|
||||||
coin = coins.by_name('Testnet')
|
coin = coins.by_name('Testnet')
|
||||||
coinsig = bitcoin.Bitcoin()
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
|
|
||||||
inp1 = TxInputType(
|
inp1 = TxInputType(
|
||||||
@ -113,7 +112,7 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase):
|
|||||||
)),
|
)),
|
||||||
TxAck(tx=TransactionType(inputs=[inp1])),
|
TxAck(tx=TransactionType(inputs=[inp1])),
|
||||||
|
|
||||||
TxRequest(request_type=TXFINISHED, details=None, serialized=TxRequestSerializedType(
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType(
|
||||||
serialized_tx=unhexlify('02483045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b950121033add1f0e8e3c3136f7428dd4a4de1057380bd311f5b0856e2269170b4ffa65bf00000000'),
|
serialized_tx=unhexlify('02483045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b950121033add1f0e8e3c3136f7428dd4a4de1057380bd311f5b0856e2269170b4ffa65bf00000000'),
|
||||||
signature_index=0,
|
signature_index=0,
|
||||||
signature=unhexlify('3045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b95'),
|
signature=unhexlify('3045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b95'),
|
||||||
@ -121,7 +120,7 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoin.Bitcoin(tx, keychain, coin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
res = signer.send(request)
|
res = signer.send(request)
|
||||||
self.assertEqual(res, response)
|
self.assertEqual(res, response)
|
||||||
@ -131,7 +130,6 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase):
|
|||||||
def test_send_native_p2wpkh_change(self):
|
def test_send_native_p2wpkh_change(self):
|
||||||
|
|
||||||
coin = coins.by_name('Testnet')
|
coin = coins.by_name('Testnet')
|
||||||
coinsig = bitcoin.Bitcoin()
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
|
|
||||||
inp1 = TxInputType(
|
inp1 = TxInputType(
|
||||||
@ -213,7 +211,7 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase):
|
|||||||
)),
|
)),
|
||||||
TxAck(tx=TransactionType(inputs=[inp1])),
|
TxAck(tx=TransactionType(inputs=[inp1])),
|
||||||
|
|
||||||
TxRequest(request_type=TXFINISHED, details=None, serialized=TxRequestSerializedType(
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType(
|
||||||
serialized_tx=unhexlify('02483045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b950121033add1f0e8e3c3136f7428dd4a4de1057380bd311f5b0856e2269170b4ffa65bf00000000'),
|
serialized_tx=unhexlify('02483045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b950121033add1f0e8e3c3136f7428dd4a4de1057380bd311f5b0856e2269170b4ffa65bf00000000'),
|
||||||
signature_index=0,
|
signature_index=0,
|
||||||
signature=unhexlify('3045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b95'),
|
signature=unhexlify('3045022100a7ca8f097525f9044e64376dc0a0f5d4aeb8d15d66808ba97979a0475b06b66502200597c8ebcef63e047f9aeef1a8001d3560470cf896c12f6990eec4faec599b95'),
|
||||||
@ -221,7 +219,7 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoin.Bitcoin(tx, keychain, coin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
self.assertEqual(signer.send(request), response)
|
self.assertEqual(signer.send(request), response)
|
||||||
with self.assertRaises(StopIteration):
|
with self.assertRaises(StopIteration):
|
||||||
@ -230,7 +228,6 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase):
|
|||||||
def test_send_native_invalid_address(self):
|
def test_send_native_invalid_address(self):
|
||||||
|
|
||||||
coin = coins.by_name('Testnet')
|
coin = coins.by_name('Testnet')
|
||||||
coinsig = bitcoin.Bitcoin()
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
|
|
||||||
inp1 = TxInputType(
|
inp1 = TxInputType(
|
||||||
@ -268,7 +265,7 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoin.Bitcoin(tx, keychain, coin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
if response is None:
|
if response is None:
|
||||||
with self.assertRaises(ScriptsError):
|
with self.assertRaises(ScriptsError):
|
||||||
|
@ -30,7 +30,6 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase):
|
|||||||
def test_send_native_p2wpkh(self):
|
def test_send_native_p2wpkh(self):
|
||||||
|
|
||||||
coin = coins.by_name('Groestlcoin Testnet')
|
coin = coins.by_name('Groestlcoin Testnet')
|
||||||
coinsig = bitcoinlike.Bitcoinlike()
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
|
|
||||||
inp1 = TxInputType(
|
inp1 = TxInputType(
|
||||||
@ -114,7 +113,7 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase):
|
|||||||
)),
|
)),
|
||||||
TxAck(tx=TransactionType(inputs=[inp1])),
|
TxAck(tx=TransactionType(inputs=[inp1])),
|
||||||
|
|
||||||
TxRequest(request_type=TXFINISHED, details=None, serialized=TxRequestSerializedType(
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType(
|
||||||
serialized_tx=unhexlify('02483045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3012103adc58245cf28406af0ef5cc24b8afba7f1be6c72f279b642d85c48798685f862d9ed0900'),
|
serialized_tx=unhexlify('02483045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3012103adc58245cf28406af0ef5cc24b8afba7f1be6c72f279b642d85c48798685f862d9ed0900'),
|
||||||
signature_index=0,
|
signature_index=0,
|
||||||
signature=unhexlify('3045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3'),
|
signature=unhexlify('3045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3'),
|
||||||
@ -122,7 +121,7 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
self.assertEqual(signer.send(request), response)
|
self.assertEqual(signer.send(request), response)
|
||||||
with self.assertRaises(StopIteration):
|
with self.assertRaises(StopIteration):
|
||||||
@ -131,7 +130,6 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase):
|
|||||||
def test_send_native_p2wpkh_change(self):
|
def test_send_native_p2wpkh_change(self):
|
||||||
|
|
||||||
coin = coins.by_name('Groestlcoin Testnet')
|
coin = coins.by_name('Groestlcoin Testnet')
|
||||||
coinsig = bitcoinlike.Bitcoinlike()
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
|
|
||||||
inp1 = TxInputType(
|
inp1 = TxInputType(
|
||||||
@ -213,7 +211,7 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase):
|
|||||||
)),
|
)),
|
||||||
TxAck(tx=TransactionType(inputs=[inp1])),
|
TxAck(tx=TransactionType(inputs=[inp1])),
|
||||||
|
|
||||||
TxRequest(request_type=TXFINISHED, details=None, serialized=TxRequestSerializedType(
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType(
|
||||||
serialized_tx=unhexlify('02483045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3012103adc58245cf28406af0ef5cc24b8afba7f1be6c72f279b642d85c48798685f862d9ed0900'),
|
serialized_tx=unhexlify('02483045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3012103adc58245cf28406af0ef5cc24b8afba7f1be6c72f279b642d85c48798685f862d9ed0900'),
|
||||||
signature_index=0,
|
signature_index=0,
|
||||||
signature=unhexlify('3045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3'),
|
signature=unhexlify('3045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3'),
|
||||||
@ -221,7 +219,7 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
self.assertEqual(signer.send(request), response)
|
self.assertEqual(signer.send(request), response)
|
||||||
with self.assertRaises(StopIteration):
|
with self.assertRaises(StopIteration):
|
||||||
|
@ -28,7 +28,6 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
|
|||||||
def test_send_p2wpkh_in_p2sh(self):
|
def test_send_p2wpkh_in_p2sh(self):
|
||||||
|
|
||||||
coin = coins.by_name('Testnet')
|
coin = coins.by_name('Testnet')
|
||||||
coinsig = bitcoin.Bitcoin()
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
|
|
||||||
inp1 = TxInputType(
|
inp1 = TxInputType(
|
||||||
@ -109,7 +108,7 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
|
|||||||
)),
|
)),
|
||||||
TxAck(tx=TransactionType(inputs=[inp1])),
|
TxAck(tx=TransactionType(inputs=[inp1])),
|
||||||
|
|
||||||
TxRequest(request_type=TXFINISHED, details=None, serialized=TxRequestSerializedType(
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType(
|
||||||
serialized_tx=unhexlify('02483045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000'),
|
serialized_tx=unhexlify('02483045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000'),
|
||||||
signature_index=0,
|
signature_index=0,
|
||||||
signature=unhexlify('3045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b'),
|
signature=unhexlify('3045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b'),
|
||||||
@ -117,7 +116,7 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoin.Bitcoin(tx, keychain, coin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
self.assertEqual(signer.send(request), response)
|
self.assertEqual(signer.send(request), response)
|
||||||
with self.assertRaises(StopIteration):
|
with self.assertRaises(StopIteration):
|
||||||
@ -126,7 +125,6 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
|
|||||||
def test_send_p2wpkh_in_p2sh_change(self):
|
def test_send_p2wpkh_in_p2sh_change(self):
|
||||||
|
|
||||||
coin = coins.by_name('Testnet')
|
coin = coins.by_name('Testnet')
|
||||||
coinsig = bitcoin.Bitcoin()
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
|
|
||||||
inp1 = TxInputType(
|
inp1 = TxInputType(
|
||||||
@ -215,7 +213,7 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
|
|||||||
)),
|
)),
|
||||||
TxAck(tx=TransactionType(inputs=[inp1])),
|
TxAck(tx=TransactionType(inputs=[inp1])),
|
||||||
|
|
||||||
TxRequest(request_type=TXFINISHED, details=None, serialized=TxRequestSerializedType(
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType(
|
||||||
serialized_tx=unhexlify(
|
serialized_tx=unhexlify(
|
||||||
'02483045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000'),
|
'02483045022100ccd253bfdf8a5593cd7b6701370c531199f0f05a418cd547dfc7da3f21515f0f02203fa08a0753688871c220648f9edadbdb98af42e5d8269364a326572cf703895b012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000'),
|
||||||
signature_index=0,
|
signature_index=0,
|
||||||
@ -224,7 +222,7 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoin.Bitcoin(tx, keychain, coin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
self.assertEqual(signer.send(request), response)
|
self.assertEqual(signer.send(request), response)
|
||||||
with self.assertRaises(StopIteration):
|
with self.assertRaises(StopIteration):
|
||||||
@ -235,7 +233,6 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
|
|||||||
def test_send_p2wpkh_in_p2sh_attack_amount(self):
|
def test_send_p2wpkh_in_p2sh_attack_amount(self):
|
||||||
|
|
||||||
coin = coins.by_name('Testnet')
|
coin = coins.by_name('Testnet')
|
||||||
coinsig = bitcoin.Bitcoin()
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
|
|
||||||
inp1 = TxInputType(
|
inp1 = TxInputType(
|
||||||
@ -332,11 +329,11 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
|
|||||||
)),
|
)),
|
||||||
TxAck(tx=TransactionType(inputs=[inp1])),
|
TxAck(tx=TransactionType(inputs=[inp1])),
|
||||||
|
|
||||||
TxRequest(request_type=TXFINISHED, details=None)
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType())
|
||||||
]
|
]
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoin.Bitcoin(tx, keychain, coin).signer()
|
||||||
i = 0
|
i = 0
|
||||||
messages_count = int(len(messages) / 2)
|
messages_count = int(len(messages) / 2)
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
|
@ -30,7 +30,6 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase):
|
|||||||
def test_send_p2wpkh_in_p2sh(self):
|
def test_send_p2wpkh_in_p2sh(self):
|
||||||
|
|
||||||
coin = coins.by_name('Groestlcoin Testnet')
|
coin = coins.by_name('Groestlcoin Testnet')
|
||||||
coinsig = bitcoinlike.Bitcoinlike()
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
|
|
||||||
inp1 = TxInputType(
|
inp1 = TxInputType(
|
||||||
@ -114,7 +113,7 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase):
|
|||||||
)),
|
)),
|
||||||
TxAck(tx=TransactionType(inputs=[inp1])),
|
TxAck(tx=TransactionType(inputs=[inp1])),
|
||||||
|
|
||||||
TxRequest(request_type=TXFINISHED, details=None, serialized=TxRequestSerializedType(
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType(
|
||||||
serialized_tx=unhexlify('02483045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7904ee0900'),
|
serialized_tx=unhexlify('02483045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7904ee0900'),
|
||||||
signature_index=0,
|
signature_index=0,
|
||||||
signature=unhexlify('3045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80'),
|
signature=unhexlify('3045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80'),
|
||||||
@ -122,7 +121,7 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
self.assertEqual(signer.send(request), response)
|
self.assertEqual(signer.send(request), response)
|
||||||
with self.assertRaises(StopIteration):
|
with self.assertRaises(StopIteration):
|
||||||
@ -131,7 +130,6 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase):
|
|||||||
def test_send_p2wpkh_in_p2sh_change(self):
|
def test_send_p2wpkh_in_p2sh_change(self):
|
||||||
|
|
||||||
coin = coins.by_name('Groestlcoin Testnet')
|
coin = coins.by_name('Groestlcoin Testnet')
|
||||||
coinsig = bitcoinlike.Bitcoinlike()
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
|
|
||||||
inp1 = TxInputType(
|
inp1 = TxInputType(
|
||||||
@ -221,7 +219,7 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase):
|
|||||||
)),
|
)),
|
||||||
TxAck(tx=TransactionType(inputs=[inp1])),
|
TxAck(tx=TransactionType(inputs=[inp1])),
|
||||||
|
|
||||||
TxRequest(request_type=TXFINISHED, details=None, serialized=TxRequestSerializedType(
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType(
|
||||||
serialized_tx=unhexlify('02483045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7904ee0900'),
|
serialized_tx=unhexlify('02483045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7904ee0900'),
|
||||||
signature_index=0,
|
signature_index=0,
|
||||||
signature=unhexlify('3045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80'),
|
signature=unhexlify('3045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80'),
|
||||||
@ -229,7 +227,7 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
self.assertEqual(signer.send(request), response)
|
self.assertEqual(signer.send(request), response)
|
||||||
with self.assertRaises(StopIteration):
|
with self.assertRaises(StopIteration):
|
||||||
|
@ -103,7 +103,6 @@ class TestSignTxFeeThreshold(unittest.TestCase):
|
|||||||
|
|
||||||
def test_under_threshold(self):
|
def test_under_threshold(self):
|
||||||
coin_bitcoin = coins.by_name('Bitcoin')
|
coin_bitcoin = coins.by_name('Bitcoin')
|
||||||
coinsig = bitcoin.Bitcoin()
|
|
||||||
|
|
||||||
ptx1 = TransactionType(version=1, lock_time=0, inputs_cnt=2, outputs_cnt=1, extra_data_len=0)
|
ptx1 = TransactionType(version=1, lock_time=0, inputs_cnt=2, outputs_cnt=1, extra_data_len=0)
|
||||||
pinp1 = TxInputType(script_sig=unhexlify('483045022072ba61305fe7cb542d142b8f3299a7b10f9ea61f6ffaab5dca8142601869d53c0221009a8027ed79eb3b9bc13577ac2853269323434558528c6b6a7e542be46e7e9a820141047a2d177c0f3626fc68c53610b0270fa6156181f46586c679ba6a88b34c6f4874686390b4d92e5769fbb89c8050b984f4ec0b257a0e5c4ff8bd3b035a51709503'),
|
pinp1 = TxInputType(script_sig=unhexlify('483045022072ba61305fe7cb542d142b8f3299a7b10f9ea61f6ffaab5dca8142601869d53c0221009a8027ed79eb3b9bc13577ac2853269323434558528c6b6a7e542be46e7e9a820141047a2d177c0f3626fc68c53610b0270fa6156181f46586c679ba6a88b34c6f4874686390b4d92e5769fbb89c8050b984f4ec0b257a0e5c4ff8bd3b035a51709503'),
|
||||||
@ -163,7 +162,7 @@ class TestSignTxFeeThreshold(unittest.TestCase):
|
|||||||
seed = bip39.seed('alcohol woman abuse must during monitor noble actual mixed trade anger aisle', '')
|
seed = bip39.seed('alcohol woman abuse must during monitor noble actual mixed trade anger aisle', '')
|
||||||
|
|
||||||
keychain = Keychain(seed, [[coin_bitcoin.curve_name]])
|
keychain = Keychain(seed, [[coin_bitcoin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin_bitcoin)
|
signer = bitcoin.Bitcoin(tx, keychain, coin_bitcoin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
res = signer.send(request)
|
res = signer.send(request)
|
||||||
self.assertEqual(res, response)
|
self.assertEqual(res, response)
|
||||||
|
@ -30,7 +30,6 @@ class TestSignTx(unittest.TestCase):
|
|||||||
# input 0: 0.0039 BTC
|
# input 0: 0.0039 BTC
|
||||||
|
|
||||||
coin_bitcoin = coins.by_name('Bitcoin')
|
coin_bitcoin = coins.by_name('Bitcoin')
|
||||||
coinsig = bitcoin.Bitcoin()
|
|
||||||
|
|
||||||
ptx1 = TransactionType(version=1, lock_time=0, inputs_cnt=2, outputs_cnt=1, extra_data_len=0)
|
ptx1 = TransactionType(version=1, lock_time=0, inputs_cnt=2, outputs_cnt=1, extra_data_len=0)
|
||||||
pinp1 = TxInputType(script_sig=unhexlify('483045022072ba61305fe7cb542d142b8f3299a7b10f9ea61f6ffaab5dca8142601869d53c0221009a8027ed79eb3b9bc13577ac2853269323434558528c6b6a7e542be46e7e9a820141047a2d177c0f3626fc68c53610b0270fa6156181f46586c679ba6a88b34c6f4874686390b4d92e5769fbb89c8050b984f4ec0b257a0e5c4ff8bd3b035a51709503'),
|
pinp1 = TxInputType(script_sig=unhexlify('483045022072ba61305fe7cb542d142b8f3299a7b10f9ea61f6ffaab5dca8142601869d53c0221009a8027ed79eb3b9bc13577ac2853269323434558528c6b6a7e542be46e7e9a820141047a2d177c0f3626fc68c53610b0270fa6156181f46586c679ba6a88b34c6f4874686390b4d92e5769fbb89c8050b984f4ec0b257a0e5c4ff8bd3b035a51709503'),
|
||||||
@ -93,7 +92,7 @@ class TestSignTx(unittest.TestCase):
|
|||||||
signature=unhexlify('30450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede781'),
|
signature=unhexlify('30450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede781'),
|
||||||
serialized_tx=unhexlify('82488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede7810121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff01'))),
|
serialized_tx=unhexlify('82488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede7810121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff01'))),
|
||||||
TxAck(tx=TransactionType(outputs=[out1])),
|
TxAck(tx=TransactionType(outputs=[out1])),
|
||||||
TxRequest(request_type=TXFINISHED, details=None, serialized=TxRequestSerializedType(
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType(
|
||||||
signature_index=None,
|
signature_index=None,
|
||||||
signature=None,
|
signature=None,
|
||||||
serialized_tx=unhexlify('60cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000'),
|
serialized_tx=unhexlify('60cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000'),
|
||||||
@ -102,7 +101,7 @@ class TestSignTx(unittest.TestCase):
|
|||||||
|
|
||||||
seed = bip39.seed('alcohol woman abuse must during monitor noble actual mixed trade anger aisle', '')
|
seed = bip39.seed('alcohol woman abuse must during monitor noble actual mixed trade anger aisle', '')
|
||||||
keychain = Keychain(seed, [[coin_bitcoin.curve_name]])
|
keychain = Keychain(seed, [[coin_bitcoin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin_bitcoin)
|
signer = bitcoin.Bitcoin(tx, keychain, coin_bitcoin).signer()
|
||||||
|
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
res = signer.send(request)
|
res = signer.send(request)
|
||||||
|
@ -31,7 +31,6 @@ class TestSignTx_GRS(unittest.TestCase):
|
|||||||
# ptx1: http://groestlsight.groestlcoin.org/api/tx/cb74c8478c5814742c87cffdb4a21231869888f8042fb07a90e015a9db1f9d4a
|
# ptx1: http://groestlsight.groestlcoin.org/api/tx/cb74c8478c5814742c87cffdb4a21231869888f8042fb07a90e015a9db1f9d4a
|
||||||
|
|
||||||
coin = coins.by_name('Groestlcoin')
|
coin = coins.by_name('Groestlcoin')
|
||||||
coinsig = bitcoinlike.Bitcoinlike()
|
|
||||||
|
|
||||||
ptx1 = TransactionType(version=1, lock_time=2160993, inputs_cnt=1, outputs_cnt=1, extra_data_len=0)
|
ptx1 = TransactionType(version=1, lock_time=2160993, inputs_cnt=1, outputs_cnt=1, extra_data_len=0)
|
||||||
pinp1 = TxInputType(script_sig=unhexlify('48304502210096a287593b1212a188e778596eb8ecd4cc169b93a4d115226460d8e3deae431c02206c78ec09b3df977f04a6df5eb53181165c4ea5a0b35f826551349130f879d6b8012102cf5126ff54e38a80a919579d7091cafe24840eab1d30fe2b4d59bdd9d267cad8'),
|
pinp1 = TxInputType(script_sig=unhexlify('48304502210096a287593b1212a188e778596eb8ecd4cc169b93a4d115226460d8e3deae431c02206c78ec09b3df977f04a6df5eb53181165c4ea5a0b35f826551349130f879d6b8012102cf5126ff54e38a80a919579d7091cafe24840eab1d30fe2b4d59bdd9d267cad8'),
|
||||||
@ -86,7 +85,7 @@ class TestSignTx_GRS(unittest.TestCase):
|
|||||||
signature=unhexlify('304402201fb96d20d0778f54520ab59afe70d5fb20e500ecc9f02281cf57934e8029e8e10220383d5a3e80f2e1eb92765b6da0f23d454aecbd8236f083d483e9a74302368761'),
|
signature=unhexlify('304402201fb96d20d0778f54520ab59afe70d5fb20e500ecc9f02281cf57934e8029e8e10220383d5a3e80f2e1eb92765b6da0f23d454aecbd8236f083d483e9a74302368761'),
|
||||||
serialized_tx=unhexlify('4a9d1fdba915e0907ab02f04f88898863112a2b4fdcf872c7414588c47c874cb000000006a47304402201fb96d20d0778f54520ab59afe70d5fb20e500ecc9f02281cf57934e8029e8e10220383d5a3e80f2e1eb92765b6da0f23d454aecbd8236f083d483e9a7430236876101210331693756f749180aeed0a65a0fab0625a2250bd9abca502282a4cf0723152e67ffffffff01'))),
|
serialized_tx=unhexlify('4a9d1fdba915e0907ab02f04f88898863112a2b4fdcf872c7414588c47c874cb000000006a47304402201fb96d20d0778f54520ab59afe70d5fb20e500ecc9f02281cf57934e8029e8e10220383d5a3e80f2e1eb92765b6da0f23d454aecbd8236f083d483e9a7430236876101210331693756f749180aeed0a65a0fab0625a2250bd9abca502282a4cf0723152e67ffffffff01'))),
|
||||||
TxAck(tx=TransactionType(outputs=[out1])),
|
TxAck(tx=TransactionType(outputs=[out1])),
|
||||||
TxRequest(request_type=TXFINISHED, details=None, serialized=TxRequestSerializedType(
|
TxRequest(request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType(
|
||||||
signature_index=None,
|
signature_index=None,
|
||||||
signature=None,
|
signature=None,
|
||||||
serialized_tx=unhexlify('a0330300000000001976a914fe40329c95c5598ac60752a5310b320cb52d18e688ac00000000'),
|
serialized_tx=unhexlify('a0330300000000001976a914fe40329c95c5598ac60752a5310b320cb52d18e688ac00000000'),
|
||||||
@ -95,7 +94,7 @@ class TestSignTx_GRS(unittest.TestCase):
|
|||||||
|
|
||||||
seed = bip39.seed(' '.join(['all'] * 12), '')
|
seed = bip39.seed(' '.join(['all'] * 12), '')
|
||||||
keychain = Keychain(seed, [[coin.curve_name]])
|
keychain = Keychain(seed, [[coin.curve_name]])
|
||||||
signer = coinsig.signer(tx, keychain, coin)
|
signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer()
|
||||||
for request, response in chunks(messages, 2):
|
for request, response in chunks(messages, 2):
|
||||||
self.assertEqual(signer.send(request), response)
|
self.assertEqual(signer.send(request), response)
|
||||||
with self.assertRaises(StopIteration):
|
with self.assertRaises(StopIteration):
|
||||||
|
@ -161,8 +161,7 @@ class TestZcashZip143(unittest.TestCase):
|
|||||||
txi.prev_index = i["prevout"][1]
|
txi.prev_index = i["prevout"][1]
|
||||||
txi.script_type = i["script_type"]
|
txi.script_type = i["script_type"]
|
||||||
txi.sequence = i["sequence"]
|
txi.sequence = i["sequence"]
|
||||||
zip143.add_prevouts(txi)
|
zip143.add_input(txi)
|
||||||
zip143.add_sequence(txi)
|
|
||||||
for o in v["outputs"]:
|
for o in v["outputs"]:
|
||||||
txo = TxOutputBinType()
|
txo = TxOutputBinType()
|
||||||
txo.amount = o["amount"]
|
txo.amount = o["amount"]
|
||||||
|
@ -195,8 +195,7 @@ class TestZcashZip243(unittest.TestCase):
|
|||||||
txi.prev_index = i["prevout"][1]
|
txi.prev_index = i["prevout"][1]
|
||||||
txi.script_type = i["script_type"]
|
txi.script_type = i["script_type"]
|
||||||
txi.sequence = i["sequence"]
|
txi.sequence = i["sequence"]
|
||||||
zip243.add_prevouts(txi)
|
zip243.add_input(txi)
|
||||||
zip243.add_sequence(txi)
|
|
||||||
for o in v["outputs"]:
|
for o in v["outputs"]:
|
||||||
txo = TxOutputBinType()
|
txo = TxOutputBinType()
|
||||||
txo.amount = o["amount"]
|
txo.amount = o["amount"]
|
||||||
|
Loading…
Reference in New Issue
Block a user