mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-14 11:39:03 +00:00
Don't require prevtx for coins with BIP-143 fork id (#352)
Coins like Bitcoin Cash and Bitcoin Gold always use BIP-143 signatures that do not require previous transactions.
This commit is contained in:
parent
369b704f6b
commit
0428f5091c
@ -14,7 +14,7 @@
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
from . import messages
|
||||
from . import coins, messages
|
||||
from .tools import CallException, expect, normalize_nfc, session
|
||||
|
||||
|
||||
@ -91,19 +91,24 @@ def sign_tx(client, coin_name, inputs, outputs, details=None, prev_txes=None):
|
||||
# set up a transactions dict
|
||||
txes = {None: messages.TransactionType(inputs=inputs, outputs=outputs)}
|
||||
# preload all relevant transactions ahead of time
|
||||
for inp in inputs:
|
||||
if inp.script_type not in (
|
||||
messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
messages.InputScriptType.SPENDWITNESS,
|
||||
messages.InputScriptType.EXTERNAL,
|
||||
):
|
||||
try:
|
||||
prev_tx = prev_txes[inp.prev_hash]
|
||||
except Exception as e:
|
||||
raise ValueError("Could not retrieve prev_tx") from e
|
||||
if not isinstance(prev_tx, messages.TransactionType):
|
||||
raise ValueError("Invalid value for prev_tx") from None
|
||||
txes[inp.prev_hash] = prev_tx
|
||||
if coin_name in coins.by_name:
|
||||
load_prevtxes = not coins.by_name[coin_name]["force_bip143"]
|
||||
else:
|
||||
load_prevtxes = True
|
||||
if load_prevtxes:
|
||||
for inp in inputs:
|
||||
if inp.script_type not in (
|
||||
messages.InputScriptType.SPENDP2SHWITNESS,
|
||||
messages.InputScriptType.SPENDWITNESS,
|
||||
messages.InputScriptType.EXTERNAL,
|
||||
):
|
||||
try:
|
||||
prev_tx = prev_txes[inp.prev_hash]
|
||||
except Exception as e:
|
||||
raise ValueError("Could not retrieve prev_tx") from e
|
||||
if not isinstance(prev_tx, messages.TransactionType):
|
||||
raise ValueError("Invalid value for prev_tx") from None
|
||||
txes[inp.prev_hash] = prev_tx
|
||||
|
||||
if details is None:
|
||||
signtx = messages.SignTx()
|
||||
|
Loading…
Reference in New Issue
Block a user