From d6c5b84188ddc7d3961e882452213de668f04a30 Mon Sep 17 00:00:00 2001 From: Konstantin Ullrich Date: Fri, 19 Jul 2024 19:31:11 +0200 Subject: [PATCH] Fix Bitcoin not sending on Ledger (#1539) --- cw_bitcoin/lib/electrum_wallet.dart | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index 6cc82780f..39cf95009 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -519,17 +519,20 @@ abstract class ElectrumWalletBase ); spendsSilentPayment = true; isSilentPayment = true; - } else { + } else if (!isHardwareWallet) { privkey = generateECPrivate(hd: hd, index: utx.bitcoinAddressRecord.index, network: network); } vinOutpoints.add(Outpoint(txid: utx.hash, index: utx.vout)); - inputPrivKeyInfos.add(ECPrivateInfo( - privkey, - address.type == SegwitAddresType.p2tr, - tweak: !isSilentPayment, - )); + + if (privkey != null) { + inputPrivKeyInfos.add(ECPrivateInfo( + privkey, + address.type == SegwitAddresType.p2tr, + tweak: !isSilentPayment, + )); + } utxos.add( UtxoWithAddress( @@ -541,7 +544,7 @@ abstract class ElectrumWalletBase isSilentPayment: isSilentPayment, ), ownerDetails: UtxoAddressDetails( - publicKey: privkey.getPublic().toHex(), + publicKey: pubKeyHex, address: address, ), ),