mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-25 11:45:59 +00:00
detect p2tr outputs
This commit is contained in:
parent
f630c3f567
commit
b50985aec7
2 changed files with 29 additions and 5 deletions
|
@ -80,12 +80,22 @@ abstract class Bip39HDCurrency extends Bip39Currency {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Bech32 decode fail
|
// Bech32 decode fail
|
||||||
}
|
}
|
||||||
|
if (decodeBech32?.hrp != null) {
|
||||||
|
// P2TR Bech32m addresses have null hrp.
|
||||||
if (networkParams.bech32Hrp != decodeBech32!.hrp) {
|
if (networkParams.bech32Hrp != decodeBech32!.hrp) {
|
||||||
throw ArgumentError('Invalid prefix or Network mismatch');
|
throw ArgumentError('Invalid prefix or Network mismatch');
|
||||||
}
|
}
|
||||||
if (decodeBech32.version != 0) {
|
if (decodeBech32.version != 0) {
|
||||||
throw ArgumentError('Invalid address version');
|
throw ArgumentError('Invalid address version');
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// P2TR.
|
||||||
|
if (address.startsWith('bc1p') || address.startsWith('tb1p')) {
|
||||||
|
// P2TR (Taproot).
|
||||||
|
return DerivePathType.bip86;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// P2WPKH
|
// P2WPKH
|
||||||
return DerivePathType.bip84;
|
return DerivePathType.bip84;
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,6 +682,20 @@ mixin ElectrumXInterface<T extends Bip39HDCurrency> on Bip39HDWallet<T> {
|
||||||
|
|
||||||
// TODO: use coinlib
|
// TODO: use coinlib
|
||||||
|
|
||||||
|
// Check if any txData.recipients are taproot/P2TR outputs.
|
||||||
|
bool hasTaprootOutput = false;
|
||||||
|
for (final recipient in txData.recipients!) {
|
||||||
|
if (cryptoCurrency.addressType(address: recipient.address) ==
|
||||||
|
DerivePathType.bip86) {
|
||||||
|
hasTaprootOutput = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasTaprootOutput) {
|
||||||
|
// Use Coinlib to construct taproot transaction.
|
||||||
|
// TODO [prio=high]: Implement taproot transaction construction.
|
||||||
|
}
|
||||||
|
|
||||||
final txb = bitcoindart.TransactionBuilder(
|
final txb = bitcoindart.TransactionBuilder(
|
||||||
network: bitcoindart.NetworkType(
|
network: bitcoindart.NetworkType(
|
||||||
messagePrefix: cryptoCurrency.networkParams.messagePrefix,
|
messagePrefix: cryptoCurrency.networkParams.messagePrefix,
|
||||||
|
|
Loading…
Reference in a new issue