mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-12-02 20:04:40 +01:00
Contracts: only create a context on a genuine miss
get_private_context() flattened "missing context" and real store/keychain errors into one error, so the contract code created a fresh context on ANY error (e.g. a decryption failure from a wrong keychain mask), masking the real problem. - add Error::NotFoundErr; the grin_store conversion maps NotFoundErr through faithfully (other store errors stay Backend). - contract get_or_create / get_net_change / sign create-or-skip only on NotFoundErr and propagate every other error. Addresses PR #754 review (context.rs, utils.rs, sign.rs).
This commit is contained in:
@@ -377,6 +377,8 @@ where
|
||||
let (blind_xor_key, nonce_xor_key) =
|
||||
private_ctx_xor_keys(&self.keychain(keychain_mask)?, slate_id)?;
|
||||
|
||||
// A missing context surfaces as Error::NotFoundErr (via the grin_store
|
||||
// conversion), letting callers distinguish it from other store errors.
|
||||
let mut ctx: Context = option_to_not_found(self.db.get_ser(&ctx_key, None), || {
|
||||
format!("Slate id: {:x?}", slate_id.to_vec())
|
||||
})?;
|
||||
|
||||
Reference in New Issue
Block a user