mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-04 12:34:14 +01:00
feat: more info on privkey error (#1612)
This commit is contained in:
@@ -993,11 +993,29 @@ abstract class ElectrumWalletBase
|
|||||||
bool hasTaprootInputs = false;
|
bool hasTaprootInputs = false;
|
||||||
|
|
||||||
final transaction = txb.buildTransaction((txDigest, utxo, publicKey, sighash) {
|
final transaction = txb.buildTransaction((txDigest, utxo, publicKey, sighash) {
|
||||||
final key = estimatedTx.inputPrivKeyInfos
|
String error = "Cannot find private key.";
|
||||||
.firstWhereOrNull((element) => element.privkey.getPublic().toHex() == publicKey);
|
|
||||||
|
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) {
|
if (key == null) {
|
||||||
throw Exception("Cannot find private key");
|
throw Exception(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utxo.utxo.isP2tr()) {
|
if (utxo.utxo.isP2tr()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user