Fix Bitcoin not sending on Ledger (#1539)

Konstantin Ullrich committed Jul 19, 2024 at 19:31 UTC d6c5b84188ddc7d3961e882452213de668f04a30
1 file changed +10 -7
cw_bitcoin/lib/electrum_wallet.dart
+10 -7
@@ -519,17 +519,20 @@ abstract class ElectrumWalletBase
519 );
520 spendsSilentPayment = true;
521 isSilentPayment = true;
522 - } else {
522 + } else if (!isHardwareWallet) {
523 privkey =
524 generateECPrivate(hd: hd, index: utx.bitcoinAddressRecord.index, network: network);
525 }
526
527 vinOutpoints.add(Outpoint(txid: utx.hash, index: utx.vout));
528 - inputPrivKeyInfos.add(ECPrivateInfo(
529 - privkey,
530 - address.type == SegwitAddresType.p2tr,
531 - tweak: !isSilentPayment,
532 - ));
528 +
529 + if (privkey != null) {
530 + inputPrivKeyInfos.add(ECPrivateInfo(
531 + privkey,
532 + address.type == SegwitAddresType.p2tr,
533 + tweak: !isSilentPayment,
534 + ));
535 + }
536
537 utxos.add(
538 UtxoWithAddress(
@@ -541,7 +544,7 @@ abstract class ElectrumWalletBase
544 isSilentPayment: isSilentPayment,
545 ),
546 ownerDetails: UtxoAddressDetails(
544 - publicKey: privkey.getPublic().toHex(),
547 + publicKey: pubKeyHex,
548 address: address,
549 ),
550 ),