This commit is contained in:
Matthew Fosse 2024-05-10 12:17:23 -07:00
parent 68e20b25c3
commit 999058cae4
4 changed files with 18 additions and 9 deletions

View file

@ -151,10 +151,6 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
}
}
print(walletInfo.derivationInfo!.derivationType);
print(walletInfo.derivationInfo!.derivationPath);
print("@@@@@@@@@@@@@@@");
return BitcoinWallet(
mnemonic: snp.mnemonic,
xpub: snp.xpub,

View file

@ -4,7 +4,7 @@ Map<DerivationType, List<DerivationInfo>> electrum_derivations = {
DerivationType.electrum: [
DerivationInfo(
derivationType: DerivationType.electrum,
derivationPath: "m/0'",
derivationPath: "m/0'/0",
description: "Electrum",
scriptType: "p2wpkh",
),
@ -30,19 +30,19 @@ Map<DerivationType, List<DerivationInfo>> electrum_derivations = {
),
DerivationInfo(
derivationType: DerivationType.bip39,
derivationPath: "m/0'",
derivationPath: "m/0'/0",
description: "Non-standard legacy",
scriptType: "p2pkh",
),
DerivationInfo(
derivationType: DerivationType.bip39,
derivationPath: "m/0'",
derivationPath: "m/0'/0",
description: "Non-standard compatibility segwit",
scriptType: "p2wpkh-p2sh",
),
DerivationInfo(
derivationType: DerivationType.bip39,
derivationPath: "m/0'",
derivationPath: "m/0'/0",
description: "Non-standard native segwit",
scriptType: "p2wpkh",
),

View file

@ -1371,7 +1371,9 @@ abstract class ElectrumWalletBase
final HD = index == null ? hd : hd.derive(index);
final priv = ECPrivate.fromHex(HD.privKey!);
String messagePrefix = '\x18Bitcoin Signed Message:\n';
return priv.signMessage(utf8.encode(message), messagePrefix: messagePrefix);
final hexEncoded = priv.signMessage(utf8.encode(message), messagePrefix: messagePrefix);
final decodedSig = hex.decode(hexEncoded);
return base64Encode(decodedSig);
}
@override

View file

@ -766,6 +766,17 @@ Future<void> changeDefaultMoneroNode(
}
}
Future<void> fixBtcDerivationPaths(Box<WalletInfo> walletsInfoSource) async {
for (WalletInfo walletInfo in walletsInfoSource.values) {
if (walletInfo.type == WalletType.bitcoin) {
if (walletInfo.derivationInfo?.derivationPath == "m/0'") {
walletInfo.derivationInfo!.derivationPath = "m/0'/0";
}
}
await walletInfo.save();
}
}
Future<void> updateBtcNanoWalletInfos(Box<WalletInfo> walletsInfoSource) async {
for (WalletInfo walletInfo in walletsInfoSource.values) {
if (walletInfo.type == WalletType.nano || walletInfo.type == WalletType.bitcoin) {