mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
feat: more info on privkey error (#1612)
This commit is contained in:
@@ -993,11 +993,29 @@ abstract class ElectrumWalletBase
|
||||
bool hasTaprootInputs = false;
|
||||
|
||||
final transaction = txb.buildTransaction((txDigest, utxo, publicKey, sighash) {
|
||||
final key = estimatedTx.inputPrivKeyInfos
|
||||
.firstWhereOrNull((element) => element.privkey.getPublic().toHex() == publicKey);
|
||||
String error = "Cannot find private key.";
|
||||
|
||||
ECPrivateInfo? key;
|
||||
|
||||
if (estimatedTx.inputPrivKeyInfos.isEmpty) {
|
||||
error += "\nNo private keys generated.";
|
||||
} else {
|
||||
error += "\nAddress: ${utxo.ownerDetails.address.toAddress()}";
|
||||
|
||||
key = estimatedTx.inputPrivKeyInfos.firstWhereOrNull((element) {
|
||||
final elemPubkey = element.privkey.getPublic().toHex();
|
||||
if (elemPubkey == publicKey) {
|
||||
return true;
|
||||
} else {
|
||||
error += "\nExpected: $publicKey";
|
||||
error += "\nPubkey: $elemPubkey";
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (key == null) {
|
||||
throw Exception("Cannot find private key");
|
||||
throw Exception(error);
|
||||
}
|
||||
|
||||
if (utxo.utxo.isP2tr()) {
|
||||
|
||||
Reference in New Issue
Block a user