Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented avoid throwing an error if private key is missing unless .send() is executed #931

Merged
merged 8 commits into from
May 31, 2023
9 changes: 5 additions & 4 deletions src/lib/account_update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1877,10 +1877,11 @@ function addMissingSignatures(
pk.equals(accountUpdate.body.publicKey).toBoolean()
);
if (i === -1) {
let pk = PublicKey.toBase58(accountUpdate.body.publicKey);
throw Error(
`addMissingSignatures: Cannot add signature for fee payer (${pk}), private key is missing.`
);
// private key is missing, but we are not throwing an error here
// there is a change signature will be added by the wallet
// if not, error will be thrown by verifyAccountUpdate
// while .send() execution
return { body, authorization: Ledger.dummySignature() }
}
privateKey = additionalKeys[i];
}
Expand Down
8 changes: 8 additions & 0 deletions src/lib/mina.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,14 @@ async function verifyAccountUpdate(

let { commitment, fullCommitment } = transactionCommitments;

// check if addMissingSignatures failed to include a signature
// due to a missing private key
if (accountUpdate.authorization === Ledger.dummySignature()) {
let pk = PublicKey.toBase58(accountUpdate.body.publicKey);
throw Error(
`verifyAccountUpdate: Detected a missing signature for (${pk}), private key was missing.`
);
}
// we are essentially only checking if the update is empty or an actual update
function includesChange<T extends {}>(
val: T | string | null | (string | null)[]
Expand Down