re enable wrapped segwit for certain coins

This commit is contained in:
julian 2024-01-11 13:36:53 -06:00
parent dc9054138c
commit f7d162e67a
4 changed files with 66 additions and 73 deletions

View file

@ -27,7 +27,7 @@ class Bitcoin extends Bip39HDCurrency {
@override @override
List<DerivePathType> get supportedDerivationPathTypes => [ List<DerivePathType> get supportedDerivationPathTypes => [
DerivePathType.bip44, DerivePathType.bip44,
// DerivePathType.bip49, DerivePathType.bip49,
DerivePathType.bip84, DerivePathType.bip84,
]; ];
@ -107,9 +107,9 @@ class Bitcoin extends Bip39HDCurrency {
case DerivePathType.bip44: case DerivePathType.bip44:
purpose = 44; purpose = 44;
break; break;
// case DerivePathType.bip49: case DerivePathType.bip49:
// purpose = 49; purpose = 49;
// break; break;
case DerivePathType.bip84: case DerivePathType.bip84:
purpose = 84; purpose = 84;
break; break;
@ -134,26 +134,18 @@ class Bitcoin extends Bip39HDCurrency {
return (address: addr, addressType: AddressType.p2pkh); return (address: addr, addressType: AddressType.p2pkh);
// case DerivePathType.bip49: case DerivePathType.bip49:
// // addressString = P2SH( final p2wpkhScript = coinlib.P2WPKHAddress.fromPublicKey(
// // data: PaymentData( publicKey,
// // redeem: P2WPKH(data: data, network: _network).data), hrp: networkParams.bech32Hrp,
// // network: _network) ).program.script;
// // .data
// // .address!; final addr = coinlib.P2SHAddress.fromScript(
// p2wpkhScript,
// // todo ?????????????????? Does not match with current BTC version: networkParams.p2shPrefix,
// final adr = coinlib.P2WPKHAddress.fromPublicKey( );
// publicKey,
// hrp: networkParams.bech32Hrp, return (address: addr, addressType: AddressType.p2sh);
// );
// final addr = coinlib.P2SHAddress.fromHash(
// adr.program.pkHash,
// version: networkParams.p2shPrefix,
// );
//
// // TODO ??????????????
// return (address: addr, addressType: AddressType.p2sh);
case DerivePathType.bip84: case DerivePathType.bip84:
final addr = coinlib.P2WPKHAddress.fromPublicKey( final addr = coinlib.P2WPKHAddress.fromPublicKey(

View file

@ -27,7 +27,7 @@ class Litecoin extends Bip39HDCurrency {
@override @override
List<DerivePathType> get supportedDerivationPathTypes => [ List<DerivePathType> get supportedDerivationPathTypes => [
DerivePathType.bip44, DerivePathType.bip44,
// DerivePathType.bip49, DerivePathType.bip49,
DerivePathType.bip84, DerivePathType.bip84,
]; ];
@ -107,9 +107,9 @@ class Litecoin extends Bip39HDCurrency {
case DerivePathType.bip44: case DerivePathType.bip44:
purpose = 44; purpose = 44;
break; break;
// case DerivePathType.bip49: case DerivePathType.bip49:
// purpose = 49; purpose = 49;
// break; break;
case DerivePathType.bip84: case DerivePathType.bip84:
purpose = 84; purpose = 84;
break; break;
@ -134,26 +134,18 @@ class Litecoin extends Bip39HDCurrency {
return (address: addr, addressType: AddressType.p2pkh); return (address: addr, addressType: AddressType.p2pkh);
// case DerivePathType.bip49: case DerivePathType.bip49:
// // addressString = P2SH( final p2wpkhScript = coinlib.P2WPKHAddress.fromPublicKey(
// // data: PaymentData( publicKey,
// // redeem: P2WPKH(data: data, network: _network).data), hrp: networkParams.bech32Hrp,
// // network: _network) ).program.script;
// // .data
// // .address!; final addr = coinlib.P2SHAddress.fromScript(
// p2wpkhScript,
// // todo ?????????????????? Does not match with current BTC version: networkParams.p2shPrefix,
// final adr = coinlib.P2WPKHAddress.fromPublicKey( );
// publicKey,
// hrp: networkParams.bech32Hrp, return (address: addr, addressType: AddressType.p2sh);
// );
// final addr = coinlib.P2SHAddress.fromHash(
// adr.program.pkHash,
// version: networkParams.p2shPrefix,
// );
//
// // TODO ??????????????
// return (address: addr, addressType: AddressType.p2sh);
case DerivePathType.bip84: case DerivePathType.bip84:
final addr = coinlib.P2WPKHAddress.fromPublicKey( final addr = coinlib.P2WPKHAddress.fromPublicKey(

View file

@ -46,10 +46,9 @@ class Namecoin extends Bip39HDCurrency {
purpose = 44; purpose = 44;
break; break;
// TODO: [prio=low] Add P2SH support. Disable for now as our p2sh was actually p2sh-p2wpkh (wrapped segwit) case DerivePathType.bip49:
// case DerivePathType.bip49: purpose = 49;
// purpose = 49; break;
// break;
case DerivePathType.bip84: case DerivePathType.bip84:
purpose = 84; purpose = 84;
@ -116,8 +115,18 @@ class Namecoin extends Bip39HDCurrency {
return (address: addr, addressType: AddressType.p2pkh); 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: case DerivePathType.bip84:
final addr = coinlib.P2WPKHAddress.fromPublicKey( final addr = coinlib.P2WPKHAddress.fromPublicKey(
@ -157,8 +166,7 @@ class Namecoin extends Bip39HDCurrency {
List<DerivePathType> get supportedDerivationPathTypes => [ List<DerivePathType> get supportedDerivationPathTypes => [
// DerivePathType.bip16, // DerivePathType.bip16,
DerivePathType.bip44, 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, DerivePathType.bip84,
]; ];

View file

@ -578,23 +578,24 @@ mixin ElectrumXInterface on Bip39HDWallet {
) )
.data; .data;
break; break;
//
// case DerivePathType.bip49: case DerivePathType.bip49:
// final p2wpkh = bitcoindart
// input = P2s .P2WPKH(
// data: bitcoindart.PaymentData(
// final p2wpkh = P2WPKH( pubkey: pubKey,
// data: PaymentData( ),
// pubkey: Format.stringToUint8List(pubKey), network: convertedNetwork,
// ), )
// network: _network, .data;
// ).data; sd.redeemScript = p2wpkh.output;
// redeemScript = p2wpkh.output; data = bitcoindart
// data = P2SH( .P2SH(
// data: PaymentData(redeem: p2wpkh), data: bitcoindart.PaymentData(redeem: p2wpkh),
// network: _network, network: convertedNetwork,
// ).data; )
// break; .data;
break;
case DerivePathType.bip84: case DerivePathType.bip84:
// input = coinlib.P2WPKHInput( // input = coinlib.P2WPKHInput(