mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
add most basic bip86 address derivation stub
to be tested according to https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki#test-vectors
This commit is contained in:
parent
6fdfa166f2
commit
f2effa3575
3 changed files with 18 additions and 1 deletions
|
@ -164,7 +164,7 @@ enum AddressType {
|
|||
stellar,
|
||||
tezos,
|
||||
frostMS,
|
||||
;
|
||||
p2tr;
|
||||
|
||||
String get readableName {
|
||||
switch (this) {
|
||||
|
@ -196,6 +196,8 @@ enum AddressType {
|
|||
return "Tezos";
|
||||
case AddressType.frostMS:
|
||||
return "FrostMS";
|
||||
case AddressType.p2tr:
|
||||
return "Taproot"; // Why not use P2TR, P2PKH, etc.?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ enum DerivePathType {
|
|||
bch44,
|
||||
bip49,
|
||||
bip84,
|
||||
bip86,
|
||||
eth,
|
||||
eCash44,
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ class Bitcoin extends Bip39HDCurrency with PaynymCurrencyInterface {
|
|||
DerivePathType.bip44,
|
||||
DerivePathType.bip49,
|
||||
DerivePathType.bip84,
|
||||
DerivePathType.bip86, // P2TR.
|
||||
];
|
||||
|
||||
@override
|
||||
|
@ -115,6 +116,9 @@ class Bitcoin extends Bip39HDCurrency with PaynymCurrencyInterface {
|
|||
case DerivePathType.bip84:
|
||||
purpose = 84;
|
||||
break;
|
||||
case DerivePathType.bip86:
|
||||
purpose = 86;
|
||||
break;
|
||||
default:
|
||||
throw Exception("DerivePathType $derivePathType not supported");
|
||||
}
|
||||
|
@ -157,6 +161,16 @@ class Bitcoin extends Bip39HDCurrency with PaynymCurrencyInterface {
|
|||
|
||||
return (address: addr, addressType: AddressType.p2wpkh);
|
||||
|
||||
case DerivePathType.bip86:
|
||||
final taproot = coinlib.Taproot(internalKey: publicKey);
|
||||
|
||||
final addr = coinlib.P2TRAddress.fromTaproot(
|
||||
taproot,
|
||||
hrp: coinlib.Network.mainnet.bech32Hrp,
|
||||
);
|
||||
|
||||
return (address: addr, addressType: AddressType.p2tr);
|
||||
|
||||
default:
|
||||
throw Exception("DerivePathType $derivePathType not supported");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue