@1sat/actions 0.0.187 → 0.0.190

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,2 +1,2 @@
1
- export { BAP_BASKET, BAP_BITCOM_ADDRESS, BAP_KEY_ID, BAP_PROTOCOL_ID, BSV21_AUTH_BASKET, BSV21_BASKET, BSV21_DEPLOY_FUNDING_BASKET, BSV21_FEE_SATS, DEFAULT_STREAM_CHUNK_SIZE, EXCHANGE_RATE_CACHE_TTL, FUNDING_BASKET, LOCK_BASKET, LOCK_PREFIX, LOCK_SUFFIX, MAX_INSCRIPTION_BYTES, MESSAGE_SIGNING_PROTOCOL, ONESAT_MAINNET_CONTENT_URL, ONESAT_MAINNET_URL, ONESAT_TESTNET_CONTENT_URL, ONESAT_TESTNET_URL, ORDFS_STREAM_CONTENT_TYPE, ORDFS_STREAM_PARAM, P1SAT_PROTOCOL, OPNS_BASKET, ORDINALS_BASKET, BSOCIAL_BASKET, SIGMA_BASKET, ORD_LOCK_PREFIX, ORD_LOCK_SUFFIX, WOC_MAINNET_URL, WOC_TESTNET_URL, } from '@1sat/types';
1
+ export { BAP_BASKET, BAP_BITCOM_ADDRESS, BAP_KEY_ID, BAP_PROTOCOL_ID, BSV21_AUTH_BASKET, BSV21_BASKET, BSV21_DEPLOY_FUNDING_BASKET, BSV21_FEE_SATS, DEFAULT_STREAM_CHUNK_SIZE, EXCHANGE_RATE_CACHE_TTL, FUNDING_BASKET, HOSTING_BASKET, HOSTING_EXP_TAG_PREFIX, HOSTING_PAYER_TAG_PREFIX, hostingExpTag, hostingPayerTag, LOCK_BASKET, LOCK_PREFIX, LOCK_SUFFIX, MAX_INSCRIPTION_BYTES, MESSAGE_SIGNING_PROTOCOL, ONESAT_MAINNET_CONTENT_URL, ONESAT_MAINNET_URL, ONESAT_TESTNET_CONTENT_URL, ONESAT_TESTNET_URL, OPNS_BASKET, OPNS_PUBLISHED_TAG, OPNS_PUSHDROP_TEMPLATE, OPNS_REGISTER_COUNTERPARTY, OPNS_REGISTER_KEY_PREFIX, opnsRegisterKeyId, ORDFS_STREAM_CONTENT_TYPE, ORDFS_STREAM_PARAM, ORDINALS_BASKET, BSOCIAL_BASKET, SIGMA_BASKET, ORD_LOCK_PREFIX, ORD_LOCK_SUFFIX, P1SAT_PROTOCOL, readHostingExp, readHostingPayer, WOC_MAINNET_URL, WOC_TESTNET_URL, } from '@1sat/types';
2
2
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,2BAA2B,EAC3B,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,eAAe,EACf,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,GACf,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,2BAA2B,EAC3B,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EACjB,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,GACf,MAAM,aAAa,CAAA"}
package/dist/constants.js CHANGED
@@ -1,2 +1,2 @@
1
- export { BAP_BASKET, BAP_BITCOM_ADDRESS, BAP_KEY_ID, BAP_PROTOCOL_ID, BSV21_AUTH_BASKET, BSV21_BASKET, BSV21_DEPLOY_FUNDING_BASKET, BSV21_FEE_SATS, DEFAULT_STREAM_CHUNK_SIZE, EXCHANGE_RATE_CACHE_TTL, FUNDING_BASKET, LOCK_BASKET, LOCK_PREFIX, LOCK_SUFFIX, MAX_INSCRIPTION_BYTES, MESSAGE_SIGNING_PROTOCOL, ONESAT_MAINNET_CONTENT_URL, ONESAT_MAINNET_URL, ONESAT_TESTNET_CONTENT_URL, ONESAT_TESTNET_URL, ORDFS_STREAM_CONTENT_TYPE, ORDFS_STREAM_PARAM, P1SAT_PROTOCOL, OPNS_BASKET, ORDINALS_BASKET, BSOCIAL_BASKET, SIGMA_BASKET, ORD_LOCK_PREFIX, ORD_LOCK_SUFFIX, WOC_MAINNET_URL, WOC_TESTNET_URL, } from '@1sat/types';
1
+ export { BAP_BASKET, BAP_BITCOM_ADDRESS, BAP_KEY_ID, BAP_PROTOCOL_ID, BSV21_AUTH_BASKET, BSV21_BASKET, BSV21_DEPLOY_FUNDING_BASKET, BSV21_FEE_SATS, DEFAULT_STREAM_CHUNK_SIZE, EXCHANGE_RATE_CACHE_TTL, FUNDING_BASKET, HOSTING_BASKET, HOSTING_EXP_TAG_PREFIX, HOSTING_PAYER_TAG_PREFIX, hostingExpTag, hostingPayerTag, LOCK_BASKET, LOCK_PREFIX, LOCK_SUFFIX, MAX_INSCRIPTION_BYTES, MESSAGE_SIGNING_PROTOCOL, ONESAT_MAINNET_CONTENT_URL, ONESAT_MAINNET_URL, ONESAT_TESTNET_CONTENT_URL, ONESAT_TESTNET_URL, OPNS_BASKET, OPNS_PUBLISHED_TAG, OPNS_PUSHDROP_TEMPLATE, OPNS_REGISTER_COUNTERPARTY, OPNS_REGISTER_KEY_PREFIX, opnsRegisterKeyId, ORDFS_STREAM_CONTENT_TYPE, ORDFS_STREAM_PARAM, ORDINALS_BASKET, BSOCIAL_BASKET, SIGMA_BASKET, ORD_LOCK_PREFIX, ORD_LOCK_SUFFIX, P1SAT_PROTOCOL, readHostingExp, readHostingPayer, WOC_MAINNET_URL, WOC_TESTNET_URL, } from '@1sat/types';
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,2BAA2B,EAC3B,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,eAAe,EACf,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,GACf,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,2BAA2B,EAC3B,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EACjB,yBAAyB,EACzB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,GACf,MAAM,aAAa,CAAA"}
@@ -1,21 +1,18 @@
1
1
  /**
2
2
  * OpNS Module
3
3
  *
4
- * Actions for managing OpNS name identity bindings.
5
- * Registers/deregisters identity public keys on OpNS tokens via MAP metadata.
4
+ * Actions for managing OpNS names. Identity bind is a signed PushDrop on the
5
+ * name UTXO (field0 = BRC-100 identity key). Moving the name spends that
6
+ * script and re-locks under the normal ordinal formats (P2PKH / OrdLock).
6
7
  */
7
- import { type BEEF, type WalletOutput } from '@bsv/sdk';
8
+ import { type BEEF, type WalletCounterparty, type WalletOutput, type WalletProtocol } from '@bsv/sdk';
8
9
  import type { Action, ActionOptions } from '../types';
10
+ export { opnsRegisterKeyId } from '@1sat/types';
9
11
  export interface OpnsRegisterRequest extends ActionOptions {
10
12
  /** The OpNS ordinal output to register (from listOutputs) */
11
13
  ordinal: WalletOutput;
12
14
  /** BEEF — resolved automatically via ID tag if omitted */
13
15
  inputBEEF?: number[];
14
- /**
15
- * Legacy: Base58Check P2PKH address to bind instead of the wallet identity
16
- * key. Written to opns.idKey as-is. Omit for BRC-100 identity (default).
17
- */
18
- address?: string;
19
16
  }
20
17
  export interface OpnsDeregisterRequest extends ActionOptions {
21
18
  /** The OpNS ordinal output to deregister (from listOutputs) */
@@ -28,32 +25,64 @@ export interface OpnsOperationResponse {
28
25
  tx?: number[];
29
26
  error?: string;
30
27
  }
31
- /** Input for getOpnsNames action */
28
+ /** Input for getOpnsNames listOutputs-shaped; basket is always OPNS. */
32
29
  export interface GetOpnsNamesInput {
33
- /** Max number of names to return */
30
+ /** Output tags to filter (listOutputs tags) */
31
+ tags?: string[];
32
+ /** How multiple tags combine (default: any when any tags/names present) */
33
+ tagQueryMode?: 'all' | 'any';
34
+ /** Convenience: appended as `name:${n}` tags (same tagQueryMode) */
35
+ names?: string[];
36
+ /** Omit for metadata-only (no BEEF). Use entire transactions when batch BEEF is required. */
37
+ include?: 'locking scripts' | 'entire transactions';
38
+ includeCustomInstructions?: boolean;
39
+ includeTags?: boolean;
40
+ includeLabels?: boolean;
34
41
  limit?: number;
35
- /** Offset for pagination */
36
42
  offset?: number;
37
43
  }
38
44
  /** Result from getOpnsNames action */
39
45
  export interface GetOpnsNamesResult {
40
46
  outputs: WalletOutput[];
41
47
  BEEF?: BEEF;
48
+ totalOutputs?: number;
49
+ }
50
+ /** Input for internalizeOpns — receive a foreign-created OpNS mint into the wallet. */
51
+ export interface InternalizeOpnsInput {
52
+ /** Mint tx as AtomicBEEF (BRC-95) — same format internalizeAction requires */
53
+ tx: number[];
54
+ /** Spend derivation for the receive lock (same path used to build receiveAddress) */
55
+ protocolID: WalletProtocol;
56
+ keyID: string;
57
+ counterparty?: WalletCounterparty;
58
+ }
59
+ /** Result from internalizeOpns */
60
+ export interface InternalizeOpnsResult {
61
+ txid?: string;
62
+ outpoint?: string;
63
+ name?: string;
64
+ error?: string;
42
65
  }
43
66
  /**
44
- * Get OpNS names from the wallet with BEEF for spending.
67
+ * List OpNS names in the wallet. Mirrors listOutputs (fixed OPNS basket).
68
+ * Metadata-only by default; pass include: 'entire transactions' for batch BEEF.
45
69
  */
46
70
  export declare const getOpnsNames: Action<GetOpnsNamesInput, GetOpnsNamesResult>;
47
71
  /**
48
- * Register a payment binding on an OpNS name (MAP opns.idKey).
49
- * Default: wallet BRC-100 identity public key (BRC-29 paymail path).
50
- * Optional address: legacy Base58Check P2PKH binding (static destination).
72
+ * Internalize an OpNS mint delivery into the wallet model (basket, name tag, id:).
73
+ * Caller supplies BEEF + the spend derivation used for the receive lock.
74
+ */
75
+ export declare const internalizeOpns: Action<InternalizeOpnsInput, InternalizeOpnsResult>;
76
+ /**
77
+ * Bind the wallet identity key to an OpNS name via signed PushDrop.
78
+ *
79
+ * Lock: PushDrop under [0,'p 1sat'] / opns:{inputOutpoint} / anyone, forSelf.
80
+ * fields[0] = identity pubkey bytes; field-sig included (same derivation).
51
81
  */
52
82
  export declare const opnsRegister: Action<OpnsRegisterRequest, OpnsOperationResponse>;
53
83
  /**
54
- * Deregister an identity key from an OpNS name.
55
- * Transfers the OpNS ordinal to self with MAP metadata containing an empty
56
- * idKey field, explicitly clearing the identity binding on-chain.
84
+ * Remove an identity bind by self-transferring to plain P2PKH.
85
+ * Spending the PushDrop clears the on-chain bind.
57
86
  */
58
87
  export declare const opnsDeregister: Action<OpnsDeregisterRequest, OpnsOperationResponse>;
59
88
  export interface OpnsListRequest extends ActionOptions {
@@ -68,8 +97,7 @@ export interface OpnsListRequest extends ActionOptions {
68
97
  }
69
98
  /**
70
99
  * List an OpNS name for sale.
71
- * Clears the identity binding (opns.idKey) in the same transaction so the
72
- * name stops resolving to the seller's identity the moment it is listed.
100
+ * Spends the current lock (PushDrop or P2PKH); OrdLock output has no identity bind.
73
101
  */
74
102
  export declare const opnsList: Action<OpnsListRequest, OpnsOperationResponse>;
75
103
  export interface OpnsTransferRequest extends ActionOptions {
@@ -84,10 +112,9 @@ export interface OpnsTransferRequest extends ActionOptions {
84
112
  }
85
113
  /**
86
114
  * Transfer an OpNS name to a new owner.
87
- * Clears the identity binding (opns.idKey) in the same transaction so the
88
- * name stops resolving to the sender's identity once transferred.
115
+ * Spends the current lock; recipient gets plain P2PKH (bind does not carry forward).
89
116
  */
90
117
  export declare const opnsTransfer: Action<OpnsTransferRequest, OpnsOperationResponse>;
91
118
  /** All OpNS actions for registry (paid mine lives on 1sat.name / orchestrator). */
92
- export declare const opnsActions: (Action<GetOpnsNamesInput, GetOpnsNamesResult> | Action<OpnsListRequest, OpnsOperationResponse> | Action<OpnsTransferRequest, OpnsOperationResponse>)[];
119
+ export declare const opnsActions: (Action<GetOpnsNamesInput, GetOpnsNamesResult> | Action<InternalizeOpnsInput, InternalizeOpnsResult> | Action<OpnsListRequest, OpnsOperationResponse> | Action<OpnsTransferRequest, OpnsOperationResponse>)[];
93
120
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/opns/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAS,KAAK,IAAI,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAA;AAO9D,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AASrD,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACzD,6DAA6D;IAC7D,OAAO,EAAE,YAAY,CAAA;IACrB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC3D,+DAA+D;IAC/D,OAAO,EAAE,YAAY,CAAA;IACrB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,MAAM,WAAW,qBAAqB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,EAAE,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAMD,oCAAoC;AACpC,MAAM,WAAW,iBAAiB;IACjC,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED,sCAAsC;AACtC,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,IAAI,CAAC,EAAE,IAAI,CAAA;CACX;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EAAE,MAAM,EAAE,CAAA;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,mBAAmB,EAAE,qBAAqB,CA2C1E,CAAA;AAEF,mFAAmF;AACnF,eAAO,MAAM,WAAW,+MAOvB,CAAA"}
@@ -1,26 +1,97 @@
1
1
  /**
2
2
  * OpNS Module
3
3
  *
4
- * Actions for managing OpNS name identity bindings.
5
- * Registers/deregisters identity public keys on OpNS tokens via MAP metadata.
4
+ * Actions for managing OpNS names. Identity bind is a signed PushDrop on the
5
+ * name UTXO (field0 = BRC-100 identity key). Moving the name spends that
6
+ * script and re-locks under the normal ordinal formats (P2PKH / OrdLock).
6
7
  */
7
- import { P2PKH } from '@bsv/sdk';
8
- import { OPNS_BASKET } from '../constants';
9
- import { buildTransferOrdinals, listOrdinal, transferOrdinals, } from '../ordinals';
10
- import { executeTrackedAction } from '../utils/createTrackedAction';
8
+ import { OpNS } from '@1sat/templates';
9
+ import { OPNS_BASKET, OPNS_PUBLISHED_TAG, OPNS_PUSHDROP_TEMPLATE, OPNS_REGISTER_COUNTERPARTY, P1SAT_PROTOCOL, opnsRegisterKeyId, } from '@1sat/types';
10
+ import { PushDrop, Transaction, Utils, } from '@bsv/sdk';
11
+ import { buildTransferOrdinals, listOrdinal, transferOrdinals } from '../ordinals';
12
+ import { executeTrackedAction, randomActionId, } from '../utils/createTrackedAction';
11
13
  import { resolveBeef } from '../utils/resolveBeef';
12
- import { signP2PKHInput } from '../utils/signP2PKH';
14
+ import { signOrdinalInput, unlockingScriptLengthForInstructions, } from '../utils/signOrdinalInput';
15
+ export { opnsRegisterKeyId } from '@1sat/types';
16
+ /** Locate the name delivery output on an OpNS mint tx (nodes at i,i+1 → name at i+2). */
17
+ function findMintNameDelivery(tx) {
18
+ for (let i = 0; i + 2 < tx.outputs.length; i++) {
19
+ const parent = OpNS.decode(tx.outputs[i].lockingScript);
20
+ const child = OpNS.decode(tx.outputs[i + 1].lockingScript);
21
+ if (!parent || !child)
22
+ continue;
23
+ const name = child.domain.trim().slice(0, 64);
24
+ if (!name)
25
+ continue;
26
+ return { vout: i + 2, name };
27
+ }
28
+ return null;
29
+ }
30
+ // ============================================================================
31
+ // Helpers
32
+ // ============================================================================
33
+ function sourceNameFromOrdinal(ordinal) {
34
+ if (ordinal.customInstructions) {
35
+ try {
36
+ const name = JSON.parse(ordinal.customInstructions).name;
37
+ if (typeof name === 'string' && name)
38
+ return name;
39
+ }
40
+ catch { }
41
+ }
42
+ return ordinal.tags?.find((t) => t.startsWith('name:'))?.slice(5);
43
+ }
44
+ async function signSingleOrdinalInput(ctx, ordinal) {
45
+ if (!ordinal.customInstructions) {
46
+ return { error: 'missing-custom-instructions' };
47
+ }
48
+ return {
49
+ sign: async (tx) => {
50
+ const unlocking = await signOrdinalInput(ctx, tx, 0, ordinal.customInstructions);
51
+ if (typeof unlocking !== 'string')
52
+ throw new Error(unlocking.error);
53
+ return { 0: { unlockingScript: unlocking } };
54
+ },
55
+ };
56
+ }
57
+ // ============================================================================
58
+ // Actions
59
+ // ============================================================================
13
60
  /**
14
- * Get OpNS names from the wallet with BEEF for spending.
61
+ * List OpNS names in the wallet. Mirrors listOutputs (fixed OPNS basket).
62
+ * Metadata-only by default; pass include: 'entire transactions' for batch BEEF.
15
63
  */
16
64
  export const getOpnsNames = {
17
65
  meta: {
18
66
  name: 'getOpnsNames',
19
- description: 'Get OpNS names from the wallet with BEEF for spending',
67
+ description: 'List OpNS names from the wallet (metadata by default; optional BEEF)',
20
68
  category: 'opns',
21
69
  inputSchema: {
22
70
  type: 'object',
23
71
  properties: {
72
+ tags: {
73
+ type: 'array',
74
+ description: 'Filter tags (listOutputs tags)',
75
+ items: { type: 'string' },
76
+ },
77
+ tagQueryMode: {
78
+ type: 'string',
79
+ enum: ['all', 'any'],
80
+ description: 'How tags combine (default any when filtering)',
81
+ },
82
+ names: {
83
+ type: 'array',
84
+ description: 'Appended as name:${n} tags',
85
+ items: { type: 'string' },
86
+ },
87
+ include: {
88
+ type: 'string',
89
+ enum: ['locking scripts', 'entire transactions'],
90
+ description: 'Omit for metadata-only (no BEEF)',
91
+ },
92
+ includeCustomInstructions: { type: 'boolean' },
93
+ includeTags: { type: 'boolean' },
94
+ includeLabels: { type: 'boolean' },
24
95
  limit: {
25
96
  type: 'integer',
26
97
  description: 'Max names to return (default: 100)',
@@ -33,31 +104,122 @@ export const getOpnsNames = {
33
104
  },
34
105
  },
35
106
  async execute(ctx, input) {
107
+ const tags = [...(input.tags ?? [])];
108
+ for (const n of input.names ?? []) {
109
+ if (n)
110
+ tags.push(`name:${n}`);
111
+ }
112
+ const filtering = tags.length > 0;
36
113
  const result = await ctx.wallet.listOutputs({
37
114
  basket: OPNS_BASKET,
38
- includeTags: true,
39
- includeCustomInstructions: true,
40
- include: 'entire transactions',
115
+ ...(filtering && {
116
+ tags,
117
+ tagQueryMode: input.tagQueryMode ?? 'any',
118
+ }),
119
+ ...(input.include && { include: input.include }),
120
+ includeCustomInstructions: input.includeCustomInstructions ?? true,
121
+ includeTags: input.includeTags ?? true,
122
+ ...(input.includeLabels != null && {
123
+ includeLabels: input.includeLabels,
124
+ }),
41
125
  limit: input.limit ?? 100,
42
126
  offset: input.offset ?? 0,
43
127
  });
44
128
  return {
45
129
  outputs: result.outputs,
46
130
  BEEF: result.BEEF,
131
+ totalOutputs: result.totalOutputs,
47
132
  };
48
133
  },
49
134
  };
50
135
  /**
51
- * Register a payment binding on an OpNS name (MAP opns.idKey).
52
- * Default: wallet BRC-100 identity public key (BRC-29 paymail path).
53
- * Optional address: legacy Base58Check P2PKH binding (static destination).
136
+ * Internalize an OpNS mint delivery into the wallet model (basket, name tag, id:).
137
+ * Caller supplies BEEF + the spend derivation used for the receive lock.
138
+ */
139
+ export const internalizeOpns = {
140
+ meta: {
141
+ name: 'internalizeOpns',
142
+ description: 'Internalize a foreign-created OpNS mint into the wallet with tracking tags',
143
+ category: 'opns',
144
+ inputSchema: {
145
+ type: 'object',
146
+ properties: {
147
+ tx: {
148
+ type: 'array',
149
+ description: 'Mint AtomicBEEF (BRC-95) bytes',
150
+ items: { type: 'integer' },
151
+ },
152
+ protocolID: {
153
+ type: 'array',
154
+ description: 'Wallet protocol for spend derivation',
155
+ },
156
+ keyID: {
157
+ type: 'string',
158
+ description: 'Key ID for spend derivation',
159
+ },
160
+ counterparty: {
161
+ type: 'string',
162
+ description: 'Counterparty for spend derivation (default self)',
163
+ },
164
+ },
165
+ required: ['tx', 'protocolID', 'keyID'],
166
+ },
167
+ },
168
+ async execute(_ctx, input) {
169
+ try {
170
+ const parsed = Transaction.fromAtomicBEEF(input.tx);
171
+ const txid = parsed.id('hex');
172
+ const delivery = findMintNameDelivery(parsed);
173
+ if (!delivery) {
174
+ return { error: 'not-an-opns-mint' };
175
+ }
176
+ const { vout, name } = delivery;
177
+ const actionId = randomActionId();
178
+ const counterparty = input.counterparty ?? 'self';
179
+ await _ctx.wallet.internalizeAction({
180
+ tx: input.tx,
181
+ outputs: [
182
+ {
183
+ outputIndex: vout,
184
+ protocol: 'basket insertion',
185
+ insertionRemittance: {
186
+ basket: OPNS_BASKET,
187
+ tags: ['opns', `name:${name}`, `id:${actionId}_${vout}`],
188
+ customInstructions: JSON.stringify({
189
+ protocolID: input.protocolID,
190
+ keyID: input.keyID,
191
+ counterparty,
192
+ name,
193
+ }),
194
+ },
195
+ },
196
+ ],
197
+ description: `opns name ${name}`.slice(0, 50),
198
+ });
199
+ return {
200
+ txid,
201
+ outpoint: `${txid}.${vout}`,
202
+ name,
203
+ };
204
+ }
205
+ catch (err) {
206
+ return {
207
+ error: err instanceof Error ? err.message : String(err),
208
+ };
209
+ }
210
+ },
211
+ };
212
+ /**
213
+ * Bind the wallet identity key to an OpNS name via signed PushDrop.
214
+ *
215
+ * Lock: PushDrop under [0,'p 1sat'] / opns:{inputOutpoint} / anyone, forSelf.
216
+ * fields[0] = identity pubkey bytes; field-sig included (same derivation).
54
217
  */
55
218
  export const opnsRegister = {
56
219
  meta: {
57
220
  name: 'opnsRegister',
58
- description: 'Register identity key or legacy address on an OpNS name via MAP',
221
+ description: 'Bind BRC-100 identity key to an OpNS name via signed PushDrop',
59
222
  category: 'opns',
60
- requiresServices: true,
61
223
  inputSchema: {
62
224
  type: 'object',
63
225
  properties: {
@@ -69,64 +231,57 @@ export const opnsRegister = {
69
231
  type: 'array',
70
232
  description: "BEEF from listOutputs with include: 'entire transactions'",
71
233
  },
72
- address: {
73
- type: 'string',
74
- description: 'Optional Base58Check P2PKH address for legacy binding; omit for identity key',
75
- },
76
234
  },
77
235
  required: ['ordinal'],
78
236
  },
79
237
  },
80
238
  async execute(ctx, input) {
81
239
  try {
82
- if (!ctx.services) {
83
- return { error: 'services-required' };
84
- }
85
240
  const { ordinal } = input;
241
+ if (!ordinal.customInstructions) {
242
+ return { error: 'missing-custom-instructions' };
243
+ }
86
244
  const inputBEEF = input.inputBEEF ??
87
245
  (await resolveBeef(ctx.wallet, OPNS_BASKET, ordinal));
88
- let binding;
89
- if (input.address) {
90
- try {
91
- new P2PKH().lock(input.address);
92
- }
93
- catch {
94
- return { error: 'invalid-address' };
95
- }
96
- binding = input.address;
97
- }
98
- else {
99
- const { publicKey: identityPubKey } = await ctx.wallet.getPublicKey({
100
- identityKey: true,
101
- });
102
- binding = identityPubKey;
103
- }
104
- // Transfer to self with MAP binding
105
- const params = await buildTransferOrdinals(ctx, {
106
- transfers: [
246
+ const { publicKey: identityPubKey } = await ctx.wallet.getPublicKey({
247
+ identityKey: true,
248
+ });
249
+ const keyID = opnsRegisterKeyId(ordinal.outpoint);
250
+ const lockingScript = await new PushDrop(ctx.wallet).lock([Utils.toArray(identityPubKey, 'hex')], P1SAT_PROTOCOL, keyID, OPNS_REGISTER_COUNTERPARTY, true, true);
251
+ const tags = [
252
+ ...(ordinal.tags ?? []).filter((t) => t !== OPNS_PUBLISHED_TAG && !t.startsWith('ordlock')),
253
+ OPNS_PUBLISHED_TAG,
254
+ ];
255
+ const name = sourceNameFromOrdinal(ordinal);
256
+ const result = await executeTrackedAction(ctx.wallet, {
257
+ description: 'Register OpNS identity bind',
258
+ inputBEEF,
259
+ inputs: [
107
260
  {
108
- ordinal,
109
- counterparty: 'self',
110
- map: {
111
- 'opns.idKey': binding,
112
- },
113
- extraTags: ['opns:published'],
261
+ outpoint: ordinal.outpoint,
262
+ inputDescription: 'OpNS name to register',
263
+ unlockingScriptLength: unlockingScriptLengthForInstructions(ordinal.customInstructions),
264
+ },
265
+ ],
266
+ outputs: [
267
+ {
268
+ lockingScript: lockingScript.toHex(),
269
+ satoshis: 1,
270
+ outputDescription: 'OpNS identity bind',
271
+ basket: OPNS_BASKET,
272
+ tags,
273
+ customInstructions: JSON.stringify({
274
+ protocolID: P1SAT_PROTOCOL,
275
+ keyID,
276
+ counterparty: OPNS_REGISTER_COUNTERPARTY,
277
+ template: OPNS_PUSHDROP_TEMPLATE,
278
+ ...(name && { name }),
279
+ }),
114
280
  },
115
281
  ],
116
- inputBEEF,
117
- });
118
- if ('error' in params) {
119
- return params;
120
- }
121
- if (!ordinal.customInstructions) {
122
- return { error: 'missing-custom-instructions' };
123
- }
124
- const { protocolID, keyID, counterparty } = JSON.parse(ordinal.customInstructions);
125
- const result = await executeTrackedAction(ctx.wallet, {
126
- ...params,
127
282
  options: { randomizeOutputs: false },
128
283
  }, input.fundingProvider, inputBEEF, async (tx) => {
129
- const unlocking = await signP2PKHInput(ctx, tx, 0, protocolID, keyID, counterparty);
284
+ const unlocking = await signOrdinalInput(ctx, tx, 0, ordinal.customInstructions);
130
285
  if (typeof unlocking !== 'string')
131
286
  throw new Error(unlocking.error);
132
287
  return { 0: { unlockingScript: unlocking } };
@@ -150,14 +305,13 @@ export const opnsRegister = {
150
305
  },
151
306
  };
152
307
  /**
153
- * Deregister an identity key from an OpNS name.
154
- * Transfers the OpNS ordinal to self with MAP metadata containing an empty
155
- * idKey field, explicitly clearing the identity binding on-chain.
308
+ * Remove an identity bind by self-transferring to plain P2PKH.
309
+ * Spending the PushDrop clears the on-chain bind.
156
310
  */
157
311
  export const opnsDeregister = {
158
312
  meta: {
159
313
  name: 'opnsDeregister',
160
- description: 'Remove identity key binding from an OpNS name',
314
+ description: 'Remove identity bind from an OpNS name (self-transfer to P2PKH)',
161
315
  category: 'opns',
162
316
  inputSchema: {
163
317
  type: 'object',
@@ -178,15 +332,11 @@ export const opnsDeregister = {
178
332
  try {
179
333
  const { ordinal } = input;
180
334
  const inputBEEF = input.inputBEEF ?? (await resolveBeef(ctx.wallet, OPNS_BASKET, ordinal));
181
- // Transfer to self with empty idKey — explicitly clears identity binding
182
335
  const params = await buildTransferOrdinals(ctx, {
183
336
  transfers: [
184
337
  {
185
338
  ordinal,
186
339
  counterparty: 'self',
187
- map: {
188
- 'opns.idKey': '',
189
- },
190
340
  extraTags: [],
191
341
  },
192
342
  ],
@@ -195,20 +345,18 @@ export const opnsDeregister = {
195
345
  if ('error' in params) {
196
346
  return params;
197
347
  }
198
- if (!ordinal.customInstructions) {
199
- return { error: 'missing-custom-instructions' };
348
+ // Drop published tag on the plain self-transfer output
349
+ if (params.outputs?.[0]?.tags) {
350
+ params.outputs[0].tags = params.outputs[0].tags.filter((t) => t !== OPNS_PUBLISHED_TAG);
200
351
  }
201
- const { protocolID, keyID, counterparty } = JSON.parse(ordinal.customInstructions);
202
- const result = await executeTrackedAction(ctx.wallet, {
352
+ const signer = await signSingleOrdinalInput(ctx, ordinal);
353
+ if ('error' in signer)
354
+ return signer;
355
+ return await executeTrackedAction(ctx.wallet, {
203
356
  ...params,
357
+ description: 'Deregister OpNS identity bind',
204
358
  options: { randomizeOutputs: false },
205
- }, input.fundingProvider, inputBEEF, async (tx) => {
206
- const unlocking = await signP2PKHInput(ctx, tx, 0, protocolID, keyID, counterparty);
207
- if (typeof unlocking !== 'string')
208
- throw new Error(unlocking.error);
209
- return { 0: { unlockingScript: unlocking } };
210
- });
211
- return result;
359
+ }, input.fundingProvider, inputBEEF, signer.sign);
212
360
  }
213
361
  catch (error) {
214
362
  console.error('[opnsDeregister]', error);
@@ -228,13 +376,12 @@ export const opnsDeregister = {
228
376
  };
229
377
  /**
230
378
  * List an OpNS name for sale.
231
- * Clears the identity binding (opns.idKey) in the same transaction so the
232
- * name stops resolving to the seller's identity the moment it is listed.
379
+ * Spends the current lock (PushDrop or P2PKH); OrdLock output has no identity bind.
233
380
  */
234
381
  export const opnsList = {
235
382
  meta: {
236
383
  name: 'opnsList',
237
- description: 'List an OpNS name for sale, clearing its identity binding in the same transaction',
384
+ description: 'List an OpNS name for sale',
238
385
  category: 'opns',
239
386
  inputSchema: {
240
387
  type: 'object',
@@ -257,21 +404,17 @@ export const opnsList = {
257
404
  },
258
405
  },
259
406
  async execute(ctx, input) {
260
- return listOrdinal.execute(ctx, {
261
- ...input,
262
- map: { 'opns.idKey': '' },
263
- });
407
+ return listOrdinal.execute(ctx, input);
264
408
  },
265
409
  };
266
410
  /**
267
411
  * Transfer an OpNS name to a new owner.
268
- * Clears the identity binding (opns.idKey) in the same transaction so the
269
- * name stops resolving to the sender's identity once transferred.
412
+ * Spends the current lock; recipient gets plain P2PKH (bind does not carry forward).
270
413
  */
271
414
  export const opnsTransfer = {
272
415
  meta: {
273
416
  name: 'opnsTransfer',
274
- description: 'Transfer an OpNS name, clearing its identity binding in the same transaction',
417
+ description: 'Transfer an OpNS name to a new owner',
275
418
  category: 'opns',
276
419
  inputSchema: {
277
420
  type: 'object',
@@ -303,7 +446,6 @@ export const opnsTransfer = {
303
446
  ordinal: input.ordinal,
304
447
  counterparty: input.counterparty,
305
448
  address: input.address,
306
- map: { 'opns.idKey': '' },
307
449
  },
308
450
  ],
309
451
  inputBEEF: input.inputBEEF,
@@ -314,6 +456,7 @@ export const opnsTransfer = {
314
456
  /** All OpNS actions for registry (paid mine lives on 1sat.name / orchestrator). */
315
457
  export const opnsActions = [
316
458
  getOpnsNames,
459
+ internalizeOpns,
317
460
  opnsRegister,
318
461
  opnsDeregister,
319
462
  opnsList,