mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
fix(trezor): use PAYTOADDRESS script_type for external outputs (#3311)
* fix(trezor): use PAYTOADDRESS script_type for external outputs * Apply suggestion from @konstantinullrich --------- Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com> Co-authored-by: Konstantin Ullrich <konstantin@cakewallet.com>
This commit is contained in:
co-authored by
Konstantin Ullrich
Konstantin Ullrich
parent
874d724c67
commit
57a3f68755
@@ -69,12 +69,22 @@ class BitcoinTrezorService extends HardwareWalletService with BitcoinHardwareWal
|
||||
final outputCount = psbt.getGlobalOutputCount();
|
||||
for (var i = 0; i < outputCount; i++) {
|
||||
final script = Script.fromRaw(byteData: psbt.getOutputScript(i));
|
||||
// Trezor's protocol expects script_type: PAYTOADDRESS whenever the
|
||||
// output is identified by `address` (vs. own-change `addressPath`).
|
||||
// Suite parses the address string itself to determine the actual
|
||||
// on-chain script type (P2WPKH, P2TR, P2SH, etc.); script_type is
|
||||
// only semantically meaningful when addressPath is set. Passing
|
||||
// PAYTOWITNESS / PAYTOP2SHWITNESS / PAYTOTAPROOT here together with
|
||||
// `address` causes Suite to reject the deeplink as "Invalid
|
||||
// parameters from calling app" because those values specifically
|
||||
// mean "own change paid to that wallet type."
|
||||
outputs.add(TrezorTxOutput(
|
||||
amount: psbt.getOutputAmount(i),
|
||||
address: script.toAddress(),
|
||||
scriptType: _getScriptType(script.getAddressType()!)
|
||||
// ToDo: addressPath: psbt.getOutputBip32Derivation(i, pubkey).$2, // To highlight change outputs
|
||||
));
|
||||
amount: psbt.getOutputAmount(i),
|
||||
address: script.toAddress(),
|
||||
scriptType: "PAYTOADDRESS",
|
||||
// ToDo: when change-output detection lands, set addressPath + _getScriptType(...) for own-change outputs.
|
||||
// ToDo: addressPath: psbt.getOutputBip32Derivation(i, pubkey).$2, // To highlight change outputs
|
||||
));
|
||||
}
|
||||
|
||||
final signedTx = await connect.signTransaction(coin: 'btc', inputs: inputs, outputs: outputs);
|
||||
@@ -90,7 +100,8 @@ class BitcoinTrezorService extends HardwareWalletService with BitcoinHardwareWal
|
||||
}
|
||||
}
|
||||
|
||||
class LitecoinTrezorService extends HardwareWalletService with BitcoinHardwareWalletService, LitecoinHardwareWalletService {
|
||||
class LitecoinTrezorService extends HardwareWalletService
|
||||
with BitcoinHardwareWalletService, LitecoinHardwareWalletService {
|
||||
LitecoinTrezorService(this.connect);
|
||||
|
||||
final TrezorConnect connect;
|
||||
|
||||
Reference in New Issue
Block a user