@1sat/actions 0.0.151 → 0.0.152
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sweepDeposit.d.ts","sourceRoot":"","sources":["../../src/sweep/sweepDeposit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"sweepDeposit.d.ts","sourceRoot":"","sources":["../../src/sweep/sweepDeposit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAQrD,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACvD,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAgBD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CA2GtE,CAAA"}
|
|
@@ -13,25 +13,9 @@
|
|
|
13
13
|
* From that point the funds are normal BRC-29 funding, available for
|
|
14
14
|
* ordinary spending under the wallet's standard funding protocol.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import { P2PKH, PublicKey, Utils } from '@bsv/sdk';
|
|
16
|
+
import { DEPOSIT_BASKET, P1SAT_PROTOCOL } from '@1sat/types';
|
|
18
17
|
import { executeTrackedAction } from '../utils/createTrackedAction';
|
|
19
18
|
import { signP2PKHInput } from '../utils/signP2PKH';
|
|
20
|
-
/**
|
|
21
|
-
* Generate a unique keyID for the sweep destination output. The funds
|
|
22
|
-
* land at a self-derived address under BRC-29 — the keyID just needs to
|
|
23
|
-
* be unique and recoverable from the on-chain output's customInstructions.
|
|
24
|
-
* BRC-29 keyID convention is `${derivationPrefix} ${derivationSuffix}`
|
|
25
|
-
* (space-separated base64); we follow that shape with random bytes so any
|
|
26
|
-
* BRC-29-aware tooling can parse the parts.
|
|
27
|
-
*/
|
|
28
|
-
function generateSweepKeyID() {
|
|
29
|
-
const prefixBytes = new Uint8Array(4);
|
|
30
|
-
const suffixBytes = new Uint8Array(8);
|
|
31
|
-
crypto.getRandomValues(prefixBytes);
|
|
32
|
-
crypto.getRandomValues(suffixBytes);
|
|
33
|
-
return `${Utils.toBase64(Array.from(prefixBytes))} ${Utils.toBase64(Array.from(suffixBytes))}`;
|
|
34
|
-
}
|
|
35
19
|
// ============================================================================
|
|
36
20
|
// Action
|
|
37
21
|
// ============================================================================
|
|
@@ -90,20 +74,13 @@ export const sweepDeposit = {
|
|
|
90
74
|
if (inputs.length === 0) {
|
|
91
75
|
return { swept: 0 };
|
|
92
76
|
}
|
|
93
|
-
// 2.
|
|
94
|
-
//
|
|
95
|
-
// output
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
forSelf: true,
|
|
101
|
-
});
|
|
102
|
-
const destAddress = PublicKey.fromString(destPubHex).toAddress();
|
|
103
|
-
const destLockingScript = new P2PKH().lock(destAddress).toHex();
|
|
104
|
-
// 3. Build the sweep tx via createAction. Total satoshis less the
|
|
105
|
-
// wallet-allocated fee land at the destination output.
|
|
106
|
-
const totalIn = inputs.reduce((s, i) => s + i.satoshis, 0);
|
|
77
|
+
// 2. Build the sweep tx via createAction with NO explicit outputs.
|
|
78
|
+
// The wallet's own change handler creates a single BRC-29-derived
|
|
79
|
+
// change output for the full input value (less fee), recording
|
|
80
|
+
// proper derivationPrefix/derivationSuffix/senderIdentityKey
|
|
81
|
+
// columns and depositing it into the standard funding basket.
|
|
82
|
+
// That is exactly how every other BRC-29 funding output in the
|
|
83
|
+
// wallet is created — sweep just rides the same path.
|
|
107
84
|
const result = await executeTrackedAction(ctx.wallet, {
|
|
108
85
|
description: 'Sweep deposit funds',
|
|
109
86
|
inputBEEF,
|
|
@@ -112,18 +89,7 @@ export const sweepDeposit = {
|
|
|
112
89
|
inputDescription: 'Deposit sweep',
|
|
113
90
|
unlockingScriptLength: 108,
|
|
114
91
|
})),
|
|
115
|
-
outputs: [
|
|
116
|
-
{
|
|
117
|
-
lockingScript: destLockingScript,
|
|
118
|
-
satoshis: totalIn,
|
|
119
|
-
outputDescription: 'Swept funding',
|
|
120
|
-
basket: FUNDING_BASKET,
|
|
121
|
-
customInstructions: JSON.stringify({
|
|
122
|
-
protocolID: BRC29_PROTOCOL_ID,
|
|
123
|
-
keyID: destKeyID,
|
|
124
|
-
}),
|
|
125
|
-
},
|
|
126
|
-
],
|
|
92
|
+
outputs: [],
|
|
127
93
|
options: {
|
|
128
94
|
randomizeOutputs: false,
|
|
129
95
|
acceptDelayedBroadcast: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sweepDeposit.js","sourceRoot":"","sources":["../../src/sweep/sweepDeposit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"sweepDeposit.js","sourceRoot":"","sources":["../../src/sweep/sweepDeposit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AA2BnD,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,MAAM,CAAC,MAAM,YAAY,GAAkD;IAC1E,IAAI,EAAE;QACL,IAAI,EAAE,cAAc;QACpB,WAAW,EACV,sEAAsE;QACvE,QAAQ,EAAE,OAAO;QACjB,WAAW,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACX,KAAK,EAAE;oBACN,IAAI,EAAE,S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