@anywalletkit/wallet-zcash 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +14 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1104,15 +1104,22 @@ var WalletAccountZcash = class _WalletAccountZcash extends WalletAccountReadOnly
|
|
|
1104
1104
|
path;
|
|
1105
1105
|
/** Compressed secp256k1 public key. */
|
|
1106
1106
|
publicKey;
|
|
1107
|
-
/**
|
|
1108
|
-
|
|
1107
|
+
/**
|
|
1108
|
+
* The signer that holds the key, in a private field: not a property of the account, so no code
|
|
1109
|
+
* the account is handed to (a protocol module, a logger) can reach it and sign around the
|
|
1110
|
+
* account's checks (audit 2026-10-29 A1).
|
|
1111
|
+
*/
|
|
1112
|
+
#signer;
|
|
1113
|
+
/** What holds the key: `seed`, `key` (one imported key) or `external`. */
|
|
1114
|
+
signerKind;
|
|
1109
1115
|
_disposed = false;
|
|
1110
1116
|
_readOnly;
|
|
1111
1117
|
/** `publicKey` is the signer's compressed secp256k1 key (33 bytes); it is needed synchronously for the address. */
|
|
1112
1118
|
constructor(signer, publicKey, path, config = {}) {
|
|
1113
1119
|
super(addressFromPublicKey(publicKey, config.network ?? "mainnet"), config);
|
|
1114
|
-
this
|
|
1115
|
-
|
|
1120
|
+
this.#signer = (0, import_core7.requireCurve)(signer, "secp256k1");
|
|
1121
|
+
this.signerKind = this.#signer.kind;
|
|
1122
|
+
if (!this.#signer.schemes.includes("ecdsa")) throw new import_core7.SignerError(`A Zcash account needs a signer with the 'ecdsa' scheme (has: ${this.#signer.schemes.join(", ")}).`);
|
|
1116
1123
|
this.publicKey = publicKey;
|
|
1117
1124
|
this.path = path;
|
|
1118
1125
|
}
|
|
@@ -1131,7 +1138,7 @@ var WalletAccountZcash = class _WalletAccountZcash extends WalletAccountReadOnly
|
|
|
1131
1138
|
/** Zcash message signature (zcashd `signmessage` encoding), base64. */
|
|
1132
1139
|
async sign(message) {
|
|
1133
1140
|
this.live();
|
|
1134
|
-
return signMessageWith(message, this
|
|
1141
|
+
return signMessageWith(message, this.#signer);
|
|
1135
1142
|
}
|
|
1136
1143
|
ctx(intended) {
|
|
1137
1144
|
return { network: this._network, ownAddress: this.address, intended, maxFee: this.maxFee };
|
|
@@ -1163,7 +1170,7 @@ var WalletAccountZcash = class _WalletAccountZcash extends WalletAccountReadOnly
|
|
|
1163
1170
|
async #signInputs(tx, spent) {
|
|
1164
1171
|
for (let i = 0; i < tx.inputs.length; i++) {
|
|
1165
1172
|
const digest = sighashAll(tx, i, spent);
|
|
1166
|
-
const rs = await this
|
|
1173
|
+
const rs = await this.#signer.sign(digest, { scheme: "ecdsa", context: "zcash-sighash" });
|
|
1167
1174
|
const der = import_secp256k12.secp256k1.Signature.fromBytes(rs, "compact").toBytes("der");
|
|
1168
1175
|
tx.inputs[i].scriptSig = p2pkhScriptSig(der, this.publicKey);
|
|
1169
1176
|
}
|
|
@@ -1278,7 +1285,7 @@ var WalletAccountZcash = class _WalletAccountZcash extends WalletAccountReadOnly
|
|
|
1278
1285
|
}
|
|
1279
1286
|
dispose() {
|
|
1280
1287
|
this._disposed = true;
|
|
1281
|
-
this
|
|
1288
|
+
this.#signer.dispose();
|
|
1282
1289
|
}
|
|
1283
1290
|
};
|
|
1284
1291
|
|