@bsv/wallet-toolbox-client 2.10.0 → 2.10.1
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/out/index.client.cjs +24 -4
- package/out/index.client.cjs.map +1 -1
- package/out/index.client.mjs +24 -4
- package/out/index.client.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.client.mjs
CHANGED
|
@@ -7810,6 +7810,23 @@ function mergePriorOptions(caVargs, saArgs) {
|
|
|
7810
7810
|
return Validation.validateSignActionArgs(saArgs);
|
|
7811
7811
|
}
|
|
7812
7812
|
//#endregion
|
|
7813
|
+
//#region ../src/utility/canonicalizeAtomicBeef.ts
|
|
7814
|
+
/**
|
|
7815
|
+
* Restricts an AtomicBEEF envelope to the transaction named by its BRC-95
|
|
7816
|
+
* prefix and that transaction's recursive dependency closure.
|
|
7817
|
+
*
|
|
7818
|
+
* Older senders could serialize unrelated, otherwise valid BEEF branches into
|
|
7819
|
+
* an AtomicBEEF envelope. Those branches are not part of the payment proof and
|
|
7820
|
+
* must not influence internalization. Proof and transaction validation still
|
|
7821
|
+
* run against the returned closure at each wallet trust boundary.
|
|
7822
|
+
*/
|
|
7823
|
+
function canonicalizeAtomicBeef(bytes) {
|
|
7824
|
+
const received = bytes instanceof Uint8Array ? Beef.fromBinaryView(bytes) : Beef.fromBinary(bytes);
|
|
7825
|
+
const txid = received.atomicTxid;
|
|
7826
|
+
if (txid == null || received.findTxid(txid) == null || received.isAtomic(txid)) return received;
|
|
7827
|
+
return Beef.fromBinary(received.toBinaryAtomic(txid));
|
|
7828
|
+
}
|
|
7829
|
+
//#endregion
|
|
7813
7830
|
//#region ../src/signer/methods/internalizeAction.ts
|
|
7814
7831
|
/**
|
|
7815
7832
|
* Internalize Action allows a wallet to take ownership of outputs in a pre-existing transaction.
|
|
@@ -7851,7 +7868,7 @@ function mergePriorOptions(caVargs, saArgs) {
|
|
|
7851
7868
|
*/
|
|
7852
7869
|
async function internalizeAction$1(wallet, auth, args) {
|
|
7853
7870
|
const vargs = Validation.validateInternalizeActionArgs(args);
|
|
7854
|
-
const { tx } = await validateAtomicBeef();
|
|
7871
|
+
const { ab, tx, txid } = await validateAtomicBeef();
|
|
7855
7872
|
const brc29ProtocolID = [2, "3241645161d8"];
|
|
7856
7873
|
for (const o of vargs.outputs) {
|
|
7857
7874
|
if (o.outputIndex < 0 || o.outputIndex >= tx.outputs.length) throw new WERR_INVALID_PARAMETER("outputIndex", `a valid output index in range 0 to ${tx.outputs.length - 1}`);
|
|
@@ -7865,7 +7882,10 @@ async function internalizeAction$1(wallet, auth, args) {
|
|
|
7865
7882
|
default: throw new WERR_INTERNAL(`unexpected protocol ${o.protocol}`);
|
|
7866
7883
|
}
|
|
7867
7884
|
}
|
|
7868
|
-
return await wallet.storage.internalizeAction(
|
|
7885
|
+
return await wallet.storage.internalizeAction({
|
|
7886
|
+
...args,
|
|
7887
|
+
tx: ab.toBinaryAtomic(txid)
|
|
7888
|
+
});
|
|
7869
7889
|
function setupWalletPaymentForOutput(o, _dargs) {
|
|
7870
7890
|
const p = o.paymentRemittance;
|
|
7871
7891
|
const output = tx.outputs[o.outputIndex];
|
|
@@ -7888,7 +7908,7 @@ async function internalizeAction$1(wallet, auth, args) {
|
|
|
7888
7908
|
* 2. That the proofs are for the same block as recorded in the wallet's configured storage in the event of a reorg.
|
|
7889
7909
|
*/
|
|
7890
7910
|
async function validateAtomicBeef() {
|
|
7891
|
-
const ab =
|
|
7911
|
+
const ab = canonicalizeAtomicBeef(vargs.tx);
|
|
7892
7912
|
if (!await ab.verify(await wallet.getServices().getChainTracker(), false) || !ab.atomicTxid) {
|
|
7893
7913
|
console.log(`internalizeAction beef is invalid: ${ab.toLogString()}`);
|
|
7894
7914
|
throw new WERR_INVALID_PARAMETER("tx", "valid AtomicBEEF");
|
|
@@ -12421,7 +12441,7 @@ var InternalizeActionContext = class {
|
|
|
12421
12441
|
* @returns
|
|
12422
12442
|
*/
|
|
12423
12443
|
async validateAtomicBeef(atomicBeef) {
|
|
12424
|
-
const ab =
|
|
12444
|
+
const ab = canonicalizeAtomicBeef(atomicBeef);
|
|
12425
12445
|
if (!await ab.verify(await this.storage.getServices().getChainTracker(), false) || !ab.atomicTxid) throw new WERR_INVALID_PARAMETER("tx", "valid AtomicBEEF");
|
|
12426
12446
|
const txid = ab.atomicTxid;
|
|
12427
12447
|
const btx = ab.findTxid(txid);
|