mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-11 05:04:35 +00:00
re enable wrapped segwit for certain coins
This commit is contained in:
parent
dc9054138c
commit
f7d162e67a
4 changed files with 66 additions and 73 deletions
|
@ -27,7 +27,7 @@ class Bitcoin extends Bip39HDCurrency {
|
|||
@override
|
||||
List<DerivePathType> get supportedDerivationPathTypes => [
|
||||
DerivePathType.bip44,
|
||||
// DerivePathType.bip49,
|
||||
DerivePathType.bip49,
|
||||
DerivePathType.bip84,
|
||||
];
|
||||
|
||||
|
@ -107,9 +107,9 @@ class Bitcoin extends Bip39HDCurrency {
|
|||
case DerivePathType.bip44:
|
||||
purpose = 44;
|
||||
break;
|
||||
// case DerivePathType.bip49:
|
||||
// purpose = 49;
|
||||
// break;
|
||||
case DerivePathType.bip49:
|
||||
purpose = 49;
|
||||
break;
|
||||
case DerivePathType.bip84:
|
||||
purpose = 84;
|
||||
break;
|
||||
|
@ -134,26 +134,18 @@ class Bitcoin extends Bip39HDCurrency {
|
|||
|
||||
return (address: addr, addressType: AddressType.p2pkh);
|
||||
|
||||
// case DerivePathType.bip49:
|
||||
// // addressString = P2SH(
|
||||
// // data: PaymentData(
|
||||
// // redeem: P2WPKH(data: data, network: _network).data),
|
||||
// // network: _network)
|
||||
// // .data
|
||||
// // .address!;
|
||||
//
|
||||
// // todo ?????????????????? Does not match with current BTC
|
||||
// final adr = coinlib.P2WPKHAddress.fromPublicKey(
|
||||
// publicKey,
|
||||
// hrp: networkParams.bech32Hrp,
|
||||
// );
|
||||
// final addr = coinlib.P2SHAddress.fromHash(
|
||||
// adr.program.pkHash,
|
||||
// version: networkParams.p2shPrefix,
|
||||
// );
|
||||
//
|
||||
// // TODO ??????????????
|
||||
// return (address: addr, addressType: AddressType.p2sh);
|
||||
case DerivePathType.bip49:
|
||||
final p2wpkhScript = coinlib.P2WPKHAddress.fromPublicKey(
|
||||
publicKey,
|
||||
hrp: networkParams.bech32Hrp,
|
||||
).program.script;
|
||||
|
||||
final addr = coinlib.P2SHAddress.fromScript(
|
||||
p2wpkhScript,
|
||||
version: networkParams.p2shPrefix,
|
||||
);
|
||||
|
||||
return (address: addr, addressType: AddressType.p2sh);
|
||||
|
||||
case DerivePathType.bip84:
|
||||
final addr = coinlib.P2WPKHAddress.fromPublicKey(
|
||||
|
|
|
@ -27,7 +27,7 @@ class Litecoin extends Bip39HDCurrency {
|
|||
@override
|
||||
List<DerivePathType> get supportedDerivationPathTypes => [
|
||||
DerivePathType.bip44,
|
||||
// DerivePathType.bip49,
|
||||
DerivePathType.bip49,
|
||||
DerivePathType.bip84,
|
||||
];
|
||||
|
||||
|
@ -107,9 +107,9 @@ class Litecoin extends Bip39HDCurrency {
|
|||
case DerivePathType.bip44:
|
||||
purpose = 44;
|
||||
break;
|
||||
// case DerivePathType.bip49:
|
||||
// purpose = 49;
|
||||
// break;
|
||||
case DerivePathType.bip49:
|
||||
purpose = 49;
|
||||
break;
|
||||
case DerivePathType.bip84:
|
||||
purpose = 84;
|
||||
break;
|
||||
|
@ -134,26 +134,18 @@ class Litecoin extends Bip39HDCurrency {
|
|||
|
||||
return (address: addr, addressType: AddressType.p2pkh);
|
||||
|
||||
// case DerivePathType.bip49:
|
||||
// // addressString = P2SH(
|
||||
// // data: PaymentData(
|
||||
// // redeem: P2WPKH(data: data, network: _network).data),
|
||||
// // network: _network)
|
||||
// // .data
|
||||
// // .address!;
|
||||
//
|
||||
// // todo ?????????????????? Does not match with current BTC
|
||||
// final adr = coinlib.P2WPKHAddress.fromPublicKey(
|
||||
// publicKey,
|
||||
// hrp: networkParams.bech32Hrp,
|
||||
// );
|
||||
// final addr = coinlib.P2SHAddress.fromHash(
|
||||
// adr.program.pkHash,
|
||||
// version: networkParams.p2shPrefix,
|
||||
// );
|
||||
//
|
||||
// // TODO ??????????????
|
||||
// return (address: addr, addressType: AddressType.p2sh);
|
||||
case DerivePathType.bip49:
|
||||
final p2wpkhScript = coinlib.P2WPKHAddress.fromPublicKey(
|
||||
publicKey,
|
||||
hrp: networkParams.bech32Hrp,
|
||||
).program.script;
|
||||
|
||||
final addr = coinlib.P2SHAddress.fromScript(
|
||||
p2wpkhScript,
|
||||
version: networkParams.p2shPrefix,
|
||||
);
|
||||
|
||||
return (address: addr, addressType: AddressType.p2sh);
|
||||
|
||||
case DerivePathType.bip84:
|
||||
final addr = coinlib.P2WPKHAddress.fromPublicKey(
|
||||
|
|
|
@ -46,10 +46,9 @@ class Namecoin extends Bip39HDCurrency {
|
|||
purpose = 44;
|
||||
break;
|
||||
|
||||
// TODO: [prio=low] Add P2SH support. Disable for now as our p2sh was actually p2sh-p2wpkh (wrapped segwit)
|
||||
// case DerivePathType.bip49:
|
||||
// purpose = 49;
|
||||
// break;
|
||||
case DerivePathType.bip49:
|
||||
purpose = 49;
|
||||
break;
|
||||
|
||||
case DerivePathType.bip84:
|
||||
purpose = 84;
|
||||
|
@ -116,8 +115,18 @@ class Namecoin extends Bip39HDCurrency {
|
|||
|
||||
return (address: addr, addressType: AddressType.p2pkh);
|
||||
|
||||
// TODO: [prio=low] Add P2SH support. Disable for now as our p2sh was actually p2sh-p2wpkh (wrapped segwit)
|
||||
// case DerivePathType.bip49:
|
||||
case DerivePathType.bip49:
|
||||
final p2wpkhScript = coinlib.P2WPKHAddress.fromPublicKey(
|
||||
publicKey,
|
||||
hrp: networkParams.bech32Hrp,
|
||||
).program.script;
|
||||
|
||||
final addr = coinlib.P2SHAddress.fromScript(
|
||||
p2wpkhScript,
|
||||
version: networkParams.p2shPrefix,
|
||||
);
|
||||
|
||||
return (address: addr, addressType: AddressType.p2sh);
|
||||
|
||||
case DerivePathType.bip84:
|
||||
final addr = coinlib.P2WPKHAddress.fromPublicKey(
|
||||
|
@ -157,8 +166,7 @@ class Namecoin extends Bip39HDCurrency {
|
|||
List<DerivePathType> get supportedDerivationPathTypes => [
|
||||
// DerivePathType.bip16,
|
||||
DerivePathType.bip44,
|
||||
// TODO: [prio=low] Add P2SH support. Disable for now as our p2sh was actually p2sh-p2wpkh (wrapped segwit)
|
||||
// DerivePathType.bip49,
|
||||
DerivePathType.bip49,
|
||||
DerivePathType.bip84,
|
||||
];
|
||||
|
||||
|
|
|
@ -578,23 +578,24 @@ mixin ElectrumXInterface on Bip39HDWallet {
|
|||
)
|
||||
.data;
|
||||
break;
|
||||
//
|
||||
// case DerivePathType.bip49:
|
||||
//
|
||||
// input = P2s
|
||||
//
|
||||
// final p2wpkh = P2WPKH(
|
||||
// data: PaymentData(
|
||||
// pubkey: Format.stringToUint8List(pubKey),
|
||||
// ),
|
||||
// network: _network,
|
||||
// ).data;
|
||||
// redeemScript = p2wpkh.output;
|
||||
// data = P2SH(
|
||||
// data: PaymentData(redeem: p2wpkh),
|
||||
// network: _network,
|
||||
// ).data;
|
||||
// break;
|
||||
|
||||
case DerivePathType.bip49:
|
||||
final p2wpkh = bitcoindart
|
||||
.P2WPKH(
|
||||
data: bitcoindart.PaymentData(
|
||||
pubkey: pubKey,
|
||||
),
|
||||
network: convertedNetwork,
|
||||
)
|
||||
.data;
|
||||
sd.redeemScript = p2wpkh.output;
|
||||
data = bitcoindart
|
||||
.P2SH(
|
||||
data: bitcoindart.PaymentData(redeem: p2wpkh),
|
||||
network: convertedNetwork,
|
||||
)
|
||||
.data;
|
||||
break;
|
||||
|
||||
case DerivePathType.bip84:
|
||||
// input = coinlib.P2WPKHInput(
|
||||
|
|
Loading…
Reference in a new issue