@1sat/actions 0.0.178 → 0.0.180
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/sweep/sweepDeposit.d.ts.map +1 -1
- package/dist/sweep/sweepDeposit.js +5 -1
- package/dist/sweep/sweepDeposit.js.map +1 -1
- package/dist/sync/syncMessages.d.ts +4 -3
- package/dist/sync/syncMessages.d.ts.map +1 -1
- package/dist/sync/syncMessages.js +31 -30
- package/dist/sync/syncMessages.js.map +1 -1
- package/package.json +1 -1
|
@@ -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;AAIH,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;AAkBD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CAoHtE,CAAA"}
|
|
@@ -69,6 +69,10 @@ export const sweepDeposit = {
|
|
|
69
69
|
outpoint: out.outpoint,
|
|
70
70
|
keyID: parsed.keyID,
|
|
71
71
|
satoshis: out.satoshis,
|
|
72
|
+
// Legacy records predate protocol/counterparty in
|
|
73
|
+
// customInstructions; they were all P1SAT/self.
|
|
74
|
+
protocolID: parsed.protocolID ?? P1SAT_PROTOCOL,
|
|
75
|
+
counterparty: parsed.counterparty ?? 'self',
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
if (inputs.length === 0) {
|
|
@@ -97,7 +101,7 @@ export const sweepDeposit = {
|
|
|
97
101
|
}, input.fundingProvider, inputBEEF, async (tx) => {
|
|
98
102
|
const spends = {};
|
|
99
103
|
for (let i = 0; i < inputs.length; i++) {
|
|
100
|
-
const unlock = await signP2PKHInput(ctx, tx, i,
|
|
104
|
+
const unlock = await signP2PKHInput(ctx, tx, i, inputs[i].protocolID, inputs[i].keyID, inputs[i].counterparty);
|
|
101
105
|
if (typeof unlock !== 'string') {
|
|
102
106
|
throw new Error(`sweepDeposit: failed to sign input ${i}: ${unlock.error}`);
|
|
103
107
|
}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAG5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AA6BnD,+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,SAAS;oBACf,WAAW,EAAE,+CAA+C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,sCAAsC,CAAC,KAAK,MAAM,CAAC,KAAK,EAAE,CAC1D,CAAA;gBACF,CAAC;gBACD,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,CAAA;YACxC,CAAC;YACD,OAAO,MAAM,CAAA;QACd,CAAC,CACD,CAAA;QAED,OAAO;YACN,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,MAAM,CAAC,MAAM;SACpB,CAAA;IACF,CAAC;CACD,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Message Box Sync Action
|
|
3
3
|
*
|
|
4
|
-
* Polls the message box for incoming paymail payments,
|
|
5
|
-
*
|
|
6
|
-
* and acknowledges only after
|
|
4
|
+
* Polls the message box for incoming paymail payments, internalizes each
|
|
5
|
+
* one directly as a BRC-29 wallet payment (straight into the spendable
|
|
6
|
+
* balance — no deposit basket or sweep), and acknowledges only after
|
|
7
|
+
* successful internalization.
|
|
7
8
|
*/
|
|
8
9
|
import type { Action } from '../types';
|
|
9
10
|
export interface SyncMessagesInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncMessages.d.ts","sourceRoot":"","sources":["../../src/sync/syncMessages.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"syncMessages.d.ts","sourceRoot":"","sources":["../../src/sync/syncMessages.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAMtC,MAAM,WAAW,iBAAiB;IACjC,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,kBAAkB;IAClC,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAA;IACjB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAA;CACd;AAiBD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,iBAAiB,EAAE,kBAAkB,CA8GtE,CAAA"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Message Box Sync Action
|
|
3
3
|
*
|
|
4
|
-
* Polls the message box for incoming paymail payments,
|
|
5
|
-
*
|
|
6
|
-
* and acknowledges only after
|
|
4
|
+
* Polls the message box for incoming paymail payments, internalizes each
|
|
5
|
+
* one directly as a BRC-29 wallet payment (straight into the spendable
|
|
6
|
+
* balance — no deposit basket or sweep), and acknowledges only after
|
|
7
|
+
* successful internalization.
|
|
7
8
|
*/
|
|
8
|
-
import { P1SAT_PROTOCOL } from '@1sat/types';
|
|
9
9
|
import { MessageBoxClient } from '@bsv/message-box-client';
|
|
10
|
-
import { Utils } from '@bsv/sdk';
|
|
11
|
-
import { internalizeBeef, } from '../utils/internalizeBeef';
|
|
10
|
+
import { Beef, Utils } from '@bsv/sdk';
|
|
12
11
|
// ============================================================================
|
|
13
12
|
// Action
|
|
14
13
|
// ============================================================================
|
|
@@ -30,13 +29,9 @@ export const syncMessages = {
|
|
|
30
29
|
},
|
|
31
30
|
},
|
|
32
31
|
},
|
|
33
|
-
requiresServices:
|
|
32
|
+
requiresServices: false,
|
|
34
33
|
},
|
|
35
34
|
async execute(ctx, input) {
|
|
36
|
-
const services = ctx.services;
|
|
37
|
-
if (!services) {
|
|
38
|
-
throw new Error('syncMessages requires services in context');
|
|
39
|
-
}
|
|
40
35
|
const messageBox = input.messageBox || 'payment_inbox';
|
|
41
36
|
const messageboxUrl = input.messageboxUrl?.replace(/\/+$/, '') || 'https://messagebox.1sat.app';
|
|
42
37
|
// The client unwraps the server's {message, payment} envelope and
|
|
@@ -59,25 +54,31 @@ export const syncMessages = {
|
|
|
59
54
|
for (const msg of messages) {
|
|
60
55
|
try {
|
|
61
56
|
const payment = typeof msg.body === 'string' ? JSON.parse(msg.body) : msg.body;
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
57
|
+
// The transport carries plain BEEF; internalizeAction requires
|
|
58
|
+
// Atomic BEEF (BRC-95) with the subject txid.
|
|
59
|
+
const beef = Beef.fromBinary(Utils.toArray(payment.beef, 'hex'));
|
|
60
|
+
const txids = beef.txs
|
|
61
|
+
.filter((btx) => btx.tx != null)
|
|
62
|
+
.map((btx) => btx.tx.id('hex'));
|
|
63
|
+
const subjectTxid = txids[txids.length - 1];
|
|
64
|
+
// Paymail destinations are standard BRC-29 sends: internalize
|
|
65
|
+
// as a wallet payment so funds land directly in the spendable
|
|
66
|
+
// balance. The wallet derives the key from the remittance
|
|
67
|
+
// fields (senderIdentityKey is the server's anyone deriver).
|
|
68
|
+
await ctx.wallet.internalizeAction({
|
|
69
|
+
tx: beef.toBinaryAtomic(subjectTxid),
|
|
70
|
+
outputs: [
|
|
71
|
+
{
|
|
72
|
+
outputIndex: payment.outputIndex,
|
|
73
|
+
protocol: 'wallet payment',
|
|
74
|
+
paymentRemittance: {
|
|
75
|
+
derivationPrefix: payment.derivationPrefix,
|
|
76
|
+
derivationSuffix: payment.derivationSuffix,
|
|
77
|
+
senderIdentityKey: payment.senderIdentityKey,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
description: `Paymail payment to ${payment.alias}`.slice(0, 50),
|
|
81
82
|
});
|
|
82
83
|
acknowledgedIds.push(msg.messageId);
|
|
83
84
|
processed++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncMessages.js","sourceRoot":"","sources":["../../src/sync/syncMessages.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"syncMessages.js","sourceRoot":"","sources":["../../src/sync/syncMess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