@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.cjs
CHANGED
|
@@ -7845,6 +7845,23 @@ function mergePriorOptions(caVargs, saArgs) {
|
|
|
7845
7845
|
return _bsv_sdk.Validation.validateSignActionArgs(saArgs);
|
|
7846
7846
|
}
|
|
7847
7847
|
//#endregion
|
|
7848
|
+
//#region ../src/utility/canonicalizeAtomicBeef.ts
|
|
7849
|
+
/**
|
|
7850
|
+
* Restricts an AtomicBEEF envelope to the transaction named by its BRC-95
|
|
7851
|
+
* prefix and that transaction's recursive dependency closure.
|
|
7852
|
+
*
|
|
7853
|
+
* Older senders could serialize unrelated, otherwise valid BEEF branches into
|
|
7854
|
+
* an AtomicBEEF envelope. Those branches are not part of the payment proof and
|
|
7855
|
+
* must not influence internalization. Proof and transaction validation still
|
|
7856
|
+
* run against the returned closure at each wallet trust boundary.
|
|
7857
|
+
*/
|
|
7858
|
+
function canonicalizeAtomicBeef(bytes) {
|
|
7859
|
+
const received = bytes instanceof Uint8Array ? _bsv_sdk.Beef.fromBinaryView(bytes) : _bsv_sdk.Beef.fromBinary(bytes);
|
|
7860
|
+
const txid = received.atomicTxid;
|
|
7861
|
+
if (txid == null || received.findTxid(txid) == null || received.isAtomic(txid)) return received;
|
|
7862
|
+
return _bsv_sdk.Beef.fromBinary(received.toBinaryAtomic(txid));
|
|
7863
|
+
}
|
|
7864
|
+
//#endregion
|
|
7848
7865
|
//#region ../src/signer/methods/internalizeAction.ts
|
|
7849
7866
|
/**
|
|
7850
7867
|
* Internalize Action allows a wallet to take ownership of outputs in a pre-existing transaction.
|
|
@@ -7886,7 +7903,7 @@ function mergePriorOptions(caVargs, saArgs) {
|
|
|
7886
7903
|
*/
|
|
7887
7904
|
async function internalizeAction$1(wallet, auth, args) {
|
|
7888
7905
|
const vargs = _bsv_sdk.Validation.validateInternalizeActionArgs(args);
|
|
7889
|
-
const { tx } = await validateAtomicBeef();
|
|
7906
|
+
const { ab, tx, txid } = await validateAtomicBeef();
|
|
7890
7907
|
const brc29ProtocolID = [2, "3241645161d8"];
|
|
7891
7908
|
for (const o of vargs.outputs) {
|
|
7892
7909
|
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}`);
|
|
@@ -7900,7 +7917,10 @@ async function internalizeAction$1(wallet, auth, args) {
|
|
|
7900
7917
|
default: throw new WERR_INTERNAL(`unexpected protocol ${o.protocol}`);
|
|
7901
7918
|
}
|
|
7902
7919
|
}
|
|
7903
|
-
return await wallet.storage.internalizeAction(
|
|
7920
|
+
return await wallet.storage.internalizeAction({
|
|
7921
|
+
...args,
|
|
7922
|
+
tx: ab.toBinaryAtomic(txid)
|
|
7923
|
+
});
|
|
7904
7924
|
function setupWalletPaymentForOutput(o, _dargs) {
|
|
7905
7925
|
const p = o.paymentRemittance;
|
|
7906
7926
|
const output = tx.outputs[o.outputIndex];
|
|
@@ -7923,7 +7943,7 @@ async function internalizeAction$1(wallet, auth, args) {
|
|
|
7923
7943
|
* 2. That the proofs are for the same block as recorded in the wallet's configured storage in the event of a reorg.
|
|
7924
7944
|
*/
|
|
7925
7945
|
async function validateAtomicBeef() {
|
|
7926
|
-
const ab =
|
|
7946
|
+
const ab = canonicalizeAtomicBeef(vargs.tx);
|
|
7927
7947
|
if (!await ab.verify(await wallet.getServices().getChainTracker(), false) || !ab.atomicTxid) {
|
|
7928
7948
|
console.log(`internalizeAction beef is invalid: ${ab.toLogString()}`);
|
|
7929
7949
|
throw new WERR_INVALID_PARAMETER("tx", "valid AtomicBEEF");
|
|
@@ -12456,7 +12476,7 @@ var InternalizeActionContext = class {
|
|
|
12456
12476
|
* @returns
|
|
12457
12477
|
*/
|
|
12458
12478
|
async validateAtomicBeef(atomicBeef) {
|
|
12459
|
-
const ab =
|
|
12479
|
+
const ab = canonicalizeAtomicBeef(atomicBeef);
|
|
12460
12480
|
if (!await ab.verify(await this.storage.getServices().getChainTracker(), false) || !ab.atomicTxid) throw new WERR_INVALID_PARAMETER("tx", "valid AtomicBEEF");
|
|
12461
12481
|
const txid = ab.atomicTxid;
|
|
12462
12482
|
const btx = ab.findTxid(txid);
|