@1sat/templates 0.0.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/dist/bitcom/aip.d.ts +88 -0
- package/dist/bitcom/aip.d.ts.map +1 -0
- package/dist/bitcom/aip.js +205 -0
- package/dist/bitcom/aip.js.map +1 -0
- package/dist/bitcom/b.d.ts +99 -0
- package/dist/bitcom/b.d.ts.map +1 -0
- package/dist/bitcom/b.js +206 -0
- package/dist/bitcom/b.js.map +1 -0
- package/dist/bitcom/bap.d.ts +126 -0
- package/dist/bitcom/bap.d.ts.map +1 -0
- package/dist/bitcom/bap.js +334 -0
- package/dist/bitcom/bap.js.map +1 -0
- package/dist/bitcom/bitcom.d.ts +75 -0
- package/dist/bitcom/bitcom.d.ts.map +1 -0
- package/dist/bitcom/bitcom.js +186 -0
- package/dist/bitcom/bitcom.js.map +1 -0
- package/dist/bitcom/map.d.ts +90 -0
- package/dist/bitcom/map.d.ts.map +1 -0
- package/dist/bitcom/map.js +215 -0
- package/dist/bitcom/map.js.map +1 -0
- package/dist/bitcom/sigma.d.ts +93 -0
- package/dist/bitcom/sigma.d.ts.map +1 -0
- package/dist/bitcom/sigma.js +175 -0
- package/dist/bitcom/sigma.js.map +1 -0
- package/dist/bsocial/bsocial.d.ts +152 -0
- package/dist/bsocial/bsocial.d.ts.map +1 -0
- package/dist/bsocial/bsocial.js +397 -0
- package/dist/bsocial/bsocial.js.map +1 -0
- package/dist/bsv20/bsv20.d.ts +277 -0
- package/dist/bsv20/bsv20.d.ts.map +1 -0
- package/dist/bsv20/bsv20.js +544 -0
- package/dist/bsv20/bsv20.js.map +1 -0
- package/dist/bsv21/bsv21.d.ts +231 -0
- package/dist/bsv21/bsv21.d.ts.map +1 -0
- package/dist/bsv21/bsv21.js +475 -0
- package/dist/bsv21/bsv21.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/inscription/inscription.d.ts +165 -0
- package/dist/inscription/inscription.d.ts.map +1 -0
- package/dist/inscription/inscription.js +401 -0
- package/dist/inscription/inscription.js.map +1 -0
- package/dist/lock/lock.d.ts +92 -0
- package/dist/lock/lock.d.ts.map +1 -0
- package/dist/lock/lock.js +283 -0
- package/dist/lock/lock.js.map +1 -0
- package/dist/ordlock/ordlock.d.ts +126 -0
- package/dist/ordlock/ordlock.d.ts.map +1 -0
- package/dist/ordlock/ordlock.js +316 -0
- package/dist/ordlock/ordlock.js.map +1 -0
- package/dist/signer.d.ts +39 -0
- package/dist/signer.d.ts.map +1 -0
- package/dist/signer.js +54 -0
- package/dist/signer.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { ORD_LOCK_PREFIX, ORD_LOCK_SUFFIX } from '@1sat/types';
|
|
2
|
+
import { BigNumber, Hash, OP, P2PKH, Script, TransactionSignature, UnlockingScript, Utils, } from '@bsv/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* OrdLock PREFIX as number array - sCrypt contract prefix shared with Lock template
|
|
5
|
+
*/
|
|
6
|
+
export const ORDLOCK_PREFIX = Utils.toArray(ORD_LOCK_PREFIX, 'hex');
|
|
7
|
+
/**
|
|
8
|
+
* OrdLock SUFFIX as number array - contract validation script
|
|
9
|
+
*/
|
|
10
|
+
export const ORDLOCK_SUFFIX = Utils.toArray(ORD_LOCK_SUFFIX, 'hex');
|
|
11
|
+
/**
|
|
12
|
+
* Finds the index of a subarray within an array
|
|
13
|
+
*/
|
|
14
|
+
function indexOf(arr, subArr, fromIndex = 0) {
|
|
15
|
+
for (let i = fromIndex; i <= arr.length - subArr.length; i++) {
|
|
16
|
+
let found = true;
|
|
17
|
+
for (let j = 0; j < subArr.length; j++) {
|
|
18
|
+
if (arr[i + j] !== subArr[j]) {
|
|
19
|
+
found = false;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (found)
|
|
24
|
+
return i;
|
|
25
|
+
}
|
|
26
|
+
return -1;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* OrdLock - Ordinal Lock template for marketplace listings
|
|
30
|
+
*
|
|
31
|
+
* OrdLock enables trustless ordinal/NFT sales by locking an output with a
|
|
32
|
+
* contract that can only be unlocked by providing payment to a specified address.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // Decode an OrdLock from a script
|
|
37
|
+
* const ordlock = OrdLock.decode(script);
|
|
38
|
+
* if (ordlock) {
|
|
39
|
+
* console.log(`Seller: ${ordlock.seller}`);
|
|
40
|
+
* console.log(`Price: ${ordlock.price} satoshis`);
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export default class OrdLock {
|
|
45
|
+
/**
|
|
46
|
+
* Decodes an OrdLock from a script
|
|
47
|
+
*
|
|
48
|
+
* @param script - The script to decode
|
|
49
|
+
* @param mainnet - Whether to use mainnet address prefix (default: true)
|
|
50
|
+
* @returns Decoded OrdLock data or null if not found/invalid
|
|
51
|
+
*/
|
|
52
|
+
static decode(script, mainnet = true) {
|
|
53
|
+
try {
|
|
54
|
+
const scriptBinary = script.toBinary();
|
|
55
|
+
// Find PREFIX
|
|
56
|
+
const prefixIndex = indexOf(scriptBinary, ORDLOCK_PREFIX);
|
|
57
|
+
if (prefixIndex === -1)
|
|
58
|
+
return null;
|
|
59
|
+
// Find SUFFIX after PREFIX
|
|
60
|
+
const suffixIndex = indexOf(scriptBinary, ORDLOCK_SUFFIX, prefixIndex + ORDLOCK_PREFIX.length);
|
|
61
|
+
if (suffixIndex === -1)
|
|
62
|
+
return null;
|
|
63
|
+
// Extract data between PREFIX and SUFFIX
|
|
64
|
+
const dataBytes = scriptBinary.slice(prefixIndex + ORDLOCK_PREFIX.length, suffixIndex);
|
|
65
|
+
if (dataBytes.length === 0)
|
|
66
|
+
return null;
|
|
67
|
+
// Parse the data as script chunks
|
|
68
|
+
const dataScript = Script.fromBinary(dataBytes);
|
|
69
|
+
const chunks = dataScript.chunks;
|
|
70
|
+
if (chunks.length < 2)
|
|
71
|
+
return null;
|
|
72
|
+
// Chunk 0: seller PKHash (20 bytes)
|
|
73
|
+
const sellerChunk = chunks[0];
|
|
74
|
+
if (sellerChunk?.data == null || sellerChunk.data.length !== 20)
|
|
75
|
+
return null;
|
|
76
|
+
// Chunk 1: payout TransactionOutput (satoshis + locking script)
|
|
77
|
+
const payoutChunk = chunks[1];
|
|
78
|
+
if (payoutChunk?.data == null || payoutChunk.data.length < 9)
|
|
79
|
+
return null;
|
|
80
|
+
const payoutData = payoutChunk.data;
|
|
81
|
+
// Parse TransactionOutput: 8-byte LE satoshis + varint script length + script
|
|
82
|
+
// Read 8-byte little-endian satoshis
|
|
83
|
+
let price = BigInt(0);
|
|
84
|
+
for (let i = 0; i < 8; i++) {
|
|
85
|
+
price |= BigInt(payoutData[i]) << BigInt(i * 8);
|
|
86
|
+
}
|
|
87
|
+
// Convert PKHash to address
|
|
88
|
+
const addressPrefix = mainnet ? [0x00] : [0x6f];
|
|
89
|
+
const seller = Utils.toBase58Check(sellerChunk.data, addressPrefix);
|
|
90
|
+
return {
|
|
91
|
+
seller,
|
|
92
|
+
price,
|
|
93
|
+
payout: Array.from(payoutData),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Checks if a script contains an OrdLock pattern
|
|
102
|
+
*
|
|
103
|
+
* @param script - The script to check
|
|
104
|
+
* @returns true if the script contains OrdLock pattern
|
|
105
|
+
*/
|
|
106
|
+
static isOrdLock(script) {
|
|
107
|
+
const scriptBinary = script.toBinary();
|
|
108
|
+
const prefixIndex = indexOf(scriptBinary, ORDLOCK_PREFIX);
|
|
109
|
+
if (prefixIndex === -1)
|
|
110
|
+
return false;
|
|
111
|
+
const suffixIndex = indexOf(scriptBinary, ORDLOCK_SUFFIX, prefixIndex + ORDLOCK_PREFIX.length);
|
|
112
|
+
return suffixIndex !== -1;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Checks if an unlocking script indicates a purchase (vs cancellation)
|
|
116
|
+
*
|
|
117
|
+
* @param unlockingScript - The unlocking script to check
|
|
118
|
+
* @returns true if the unlock represents a purchase
|
|
119
|
+
*/
|
|
120
|
+
static isPurchase(unlockingScript) {
|
|
121
|
+
const scriptBinary = unlockingScript.toBinary();
|
|
122
|
+
return indexOf(scriptBinary, ORDLOCK_SUFFIX) !== -1;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates an OrdLock locking script for listing an ordinal
|
|
126
|
+
*
|
|
127
|
+
* @param cancelAddress - Address that can cancel the listing
|
|
128
|
+
* @param payAddress - Address that receives payment on purchase
|
|
129
|
+
* @param price - Listing price in satoshis
|
|
130
|
+
* @returns The OrdLock locking script
|
|
131
|
+
*/
|
|
132
|
+
static lock(cancelAddress, payAddress, price) {
|
|
133
|
+
const cancelPkh = Utils.fromBase58Check(cancelAddress).data;
|
|
134
|
+
const payPkh = Utils.fromBase58Check(payAddress).data;
|
|
135
|
+
return new Script()
|
|
136
|
+
.writeScript(Script.fromBinary(ORDLOCK_PREFIX))
|
|
137
|
+
.writeBin(cancelPkh)
|
|
138
|
+
.writeBin(OrdLock.buildOutput(price, new P2PKH().lock(payPkh).toBinary()))
|
|
139
|
+
.writeScript(Script.fromBinary(ORDLOCK_SUFFIX));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Builds a serialized transaction output (satoshis + script)
|
|
143
|
+
*
|
|
144
|
+
* @param satoshis - Output value
|
|
145
|
+
* @param script - Locking script as binary
|
|
146
|
+
* @returns Serialized output bytes
|
|
147
|
+
*/
|
|
148
|
+
static buildOutput(satoshis, script) {
|
|
149
|
+
const writer = new Utils.Writer();
|
|
150
|
+
writer.writeUInt64LEBn(new BigNumber(satoshis));
|
|
151
|
+
writer.writeVarIntNum(script.length);
|
|
152
|
+
writer.write(script);
|
|
153
|
+
return writer.toArray();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Creates an unlocking script for cancelling a listing
|
|
157
|
+
*
|
|
158
|
+
* @param privateKey - Private key for the cancel address
|
|
159
|
+
* @param signOutputs - Signature scope for outputs
|
|
160
|
+
* @param anyoneCanPay - Whether to use ANYONECANPAY
|
|
161
|
+
* @param sourceSatoshis - Input satoshis (optional if sourceTransaction provided)
|
|
162
|
+
* @param lockingScript - Input locking script (optional if sourceTransaction provided)
|
|
163
|
+
* @returns Unlock template with sign and estimateLength methods
|
|
164
|
+
*/
|
|
165
|
+
static cancelListing(privateKey, signOutputs = 'all', anyoneCanPay = false, sourceSatoshis, lockingScript) {
|
|
166
|
+
const p2pkh = new P2PKH().unlock(privateKey, signOutputs, anyoneCanPay, sourceSatoshis, lockingScript);
|
|
167
|
+
return {
|
|
168
|
+
sign: async (tx, inputIndex) => {
|
|
169
|
+
return (await p2pkh.sign(tx, inputIndex)).writeOpCode(OP.OP_1);
|
|
170
|
+
},
|
|
171
|
+
estimateLength: async () => {
|
|
172
|
+
return 107;
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Creates an unlocking script for cancelling a listing using a BRC-100 wallet.
|
|
178
|
+
*
|
|
179
|
+
* Uses wallet.createSignature and wallet.getPublicKey instead of a raw PrivateKey,
|
|
180
|
+
* enabling key derivation via protocolID/keyID.
|
|
181
|
+
*
|
|
182
|
+
* @param wallet - A BRC-100 WalletInterface
|
|
183
|
+
* @param protocolID - The protocol ID for key derivation
|
|
184
|
+
* @param keyID - The key ID for key derivation
|
|
185
|
+
* @param counterparty - The counterparty for key derivation (default: 'self')
|
|
186
|
+
* @returns Unlock template with sign and estimateLength methods
|
|
187
|
+
*/
|
|
188
|
+
static cancelWithWallet(wallet, protocolID, keyID, counterparty = 'self') {
|
|
189
|
+
return {
|
|
190
|
+
sign: async (tx, inputIndex) => {
|
|
191
|
+
const signatureScope = TransactionSignature.SIGHASH_ALL |
|
|
192
|
+
TransactionSignature.SIGHASH_ANYONECANPAY |
|
|
193
|
+
TransactionSignature.SIGHASH_FORKID;
|
|
194
|
+
const input = tx.inputs[inputIndex];
|
|
195
|
+
const sourceTXID = input.sourceTXID ?? input.sourceTransaction?.id('hex');
|
|
196
|
+
if (!sourceTXID) {
|
|
197
|
+
throw new Error('The input sourceTXID or sourceTransaction is required for signing.');
|
|
198
|
+
}
|
|
199
|
+
const sourceSatoshis = input.sourceTransaction?.outputs[input.sourceOutputIndex].satoshis;
|
|
200
|
+
if (!sourceSatoshis) {
|
|
201
|
+
throw new Error('The sourceSatoshis or input sourceTransaction is required for signing.');
|
|
202
|
+
}
|
|
203
|
+
const lockingScript = input.sourceTransaction?.outputs[input.sourceOutputIndex]
|
|
204
|
+
.lockingScript;
|
|
205
|
+
if (!lockingScript) {
|
|
206
|
+
throw new Error('The lockingScript or input sourceTransaction is required for signing.');
|
|
207
|
+
}
|
|
208
|
+
const preimage = TransactionSignature.format({
|
|
209
|
+
sourceTXID,
|
|
210
|
+
sourceOutputIndex: input.sourceOutputIndex,
|
|
211
|
+
sourceSatoshis,
|
|
212
|
+
transactionVersion: tx.version,
|
|
213
|
+
otherInputs: [],
|
|
214
|
+
inputIndex,
|
|
215
|
+
outputs: tx.outputs,
|
|
216
|
+
inputSequence: input.sequence ?? 0xffffffff,
|
|
217
|
+
subscript: lockingScript,
|
|
218
|
+
lockTime: tx.lockTime,
|
|
219
|
+
scope: signatureScope,
|
|
220
|
+
});
|
|
221
|
+
const sighash = Hash.sha256(Hash.sha256(preimage));
|
|
222
|
+
const { signature } = await wallet.createSignature({
|
|
223
|
+
protocolID,
|
|
224
|
+
keyID,
|
|
225
|
+
counterparty,
|
|
226
|
+
hashToDirectlySign: Array.from(sighash),
|
|
227
|
+
});
|
|
228
|
+
const { publicKey } = await wallet.getPublicKey({
|
|
229
|
+
protocolID,
|
|
230
|
+
keyID,
|
|
231
|
+
counterparty,
|
|
232
|
+
forSelf: true,
|
|
233
|
+
});
|
|
234
|
+
const sigWithHashtype = [...signature, signatureScope];
|
|
235
|
+
return new UnlockingScript()
|
|
236
|
+
.writeBin(sigWithHashtype)
|
|
237
|
+
.writeBin(Utils.toArray(publicKey, 'hex'))
|
|
238
|
+
.writeOpCode(OP.OP_1);
|
|
239
|
+
},
|
|
240
|
+
estimateLength: async () => {
|
|
241
|
+
return 108;
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Creates an unlocking script for purchasing a listing
|
|
247
|
+
*
|
|
248
|
+
* The purchase path requires:
|
|
249
|
+
* - Output 0: The ordinal going to buyer
|
|
250
|
+
* - Output 1: Payment to seller (must match payout in OrdLock)
|
|
251
|
+
* - Output 2+: Additional outputs (marketplace fees, etc.)
|
|
252
|
+
*
|
|
253
|
+
* No signature is required - the contract validates the outputs match.
|
|
254
|
+
*
|
|
255
|
+
* @param sourceSatoshis - Input satoshis (optional if sourceTransaction provided)
|
|
256
|
+
* @param lockingScript - Input locking script (optional if sourceTransaction provided)
|
|
257
|
+
* @returns Unlock template with sign and estimateLength methods
|
|
258
|
+
*/
|
|
259
|
+
static purchaseListing(sourceSatoshis, lockingScript) {
|
|
260
|
+
const purchase = {
|
|
261
|
+
sign: async (tx, inputIndex) => {
|
|
262
|
+
if (tx.outputs.length < 2) {
|
|
263
|
+
throw new Error('Malformed transaction: requires at least 2 outputs');
|
|
264
|
+
}
|
|
265
|
+
const script = new UnlockingScript().writeBin(OrdLock.buildOutput(tx.outputs[0].satoshis ?? 0, tx.outputs[0].lockingScript.toBinary()));
|
|
266
|
+
if (tx.outputs.length > 2) {
|
|
267
|
+
const writer = new Utils.Writer();
|
|
268
|
+
for (const output of tx.outputs.slice(2)) {
|
|
269
|
+
writer.write(OrdLock.buildOutput(output.satoshis ?? 0, output.lockingScript.toBinary()));
|
|
270
|
+
}
|
|
271
|
+
script.writeBin(writer.toArray());
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
script.writeOpCode(OP.OP_0);
|
|
275
|
+
}
|
|
276
|
+
const input = tx.inputs[inputIndex];
|
|
277
|
+
let sourceSats = sourceSatoshis;
|
|
278
|
+
if (!sourceSats && input.sourceTransaction != null) {
|
|
279
|
+
sourceSats = input.sourceTransaction.outputs[input.sourceOutputIndex]
|
|
280
|
+
.satoshis;
|
|
281
|
+
}
|
|
282
|
+
else if (!sourceSatoshis) {
|
|
283
|
+
throw new Error('sourceTransaction or sourceSatoshis is required');
|
|
284
|
+
}
|
|
285
|
+
const sourceTXID = (input.sourceTXID ??
|
|
286
|
+
input.sourceTransaction?.id('hex'));
|
|
287
|
+
let subscript = lockingScript;
|
|
288
|
+
if (!subscript) {
|
|
289
|
+
subscript = input.sourceTransaction?.outputs[input.sourceOutputIndex]
|
|
290
|
+
.lockingScript;
|
|
291
|
+
}
|
|
292
|
+
const preimage = TransactionSignature.format({
|
|
293
|
+
sourceTXID,
|
|
294
|
+
sourceOutputIndex: input.sourceOutputIndex,
|
|
295
|
+
sourceSatoshis: sourceSats,
|
|
296
|
+
transactionVersion: tx.version,
|
|
297
|
+
otherInputs: [],
|
|
298
|
+
inputIndex,
|
|
299
|
+
outputs: tx.outputs,
|
|
300
|
+
inputSequence: input.sequence ?? 0xffffffff,
|
|
301
|
+
subscript,
|
|
302
|
+
lockTime: tx.lockTime,
|
|
303
|
+
scope: TransactionSignature.SIGHASH_ALL |
|
|
304
|
+
TransactionSignature.SIGHASH_ANYONECANPAY |
|
|
305
|
+
TransactionSignature.SIGHASH_FORKID,
|
|
306
|
+
});
|
|
307
|
+
return script.writeBin(preimage).writeOpCode(OP.OP_0);
|
|
308
|
+
},
|
|
309
|
+
estimateLength: async (tx, inputIndex) => {
|
|
310
|
+
return (await purchase.sign(tx, inputIndex)).toBinary().length;
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
return purchase;
|
|
314
|
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AE,UAAkB,EAAE,EAAE;gBAC7D,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAA;YAC/D,CAAC;SACD,CAAA;QACD,OAAO,QAAQ,CAAA;IAChB,CAAC;CACD"}
|
package/dist/signer.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type PrivateKey, type WalletInterface, type WalletProtocol } from '@bsv/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Unified signing interface for message signing operations.
|
|
4
|
+
*
|
|
5
|
+
* Abstracts the difference between raw PrivateKey and BRC-100
|
|
6
|
+
* WalletInterface so templates don't need to know which signing
|
|
7
|
+
* backend is in use.
|
|
8
|
+
*/
|
|
9
|
+
export interface Signer {
|
|
10
|
+
/** Sign a pre-computed hash. Returns DER-encoded signature bytes. */
|
|
11
|
+
signHash: (hash: number[]) => Promise<number[]>;
|
|
12
|
+
/** Returns the compressed public key as a hex string. */
|
|
13
|
+
getPublicKey: () => Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Signer adapter for a raw PrivateKey.
|
|
17
|
+
*/
|
|
18
|
+
export declare class PrivateKeySigner implements Signer {
|
|
19
|
+
private readonly privateKey;
|
|
20
|
+
constructor(privateKey: PrivateKey);
|
|
21
|
+
signHash(hash: number[]): Promise<number[]>;
|
|
22
|
+
getPublicKey(): Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Signer adapter for a BRC-100 WalletInterface.
|
|
26
|
+
*
|
|
27
|
+
* Uses wallet.createSignature with hashToDirectlySign and
|
|
28
|
+
* wallet.getPublicKey for key derivation via protocolID/keyID.
|
|
29
|
+
*/
|
|
30
|
+
export declare class WalletSigner implements Signer {
|
|
31
|
+
private readonly wallet;
|
|
32
|
+
private readonly protocolID;
|
|
33
|
+
private readonly keyID;
|
|
34
|
+
private readonly counterparty;
|
|
35
|
+
constructor(wallet: WalletInterface, protocolID: WalletProtocol, keyID: string, counterparty?: string);
|
|
36
|
+
signHash(hash: number[]): Promise<number[]>;
|
|
37
|
+
getPublicKey(): Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,UAAU,EAEf,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,MAAM,UAAU,CAAA;AAEjB;;;;;;GAMG;AACH,MAAM,WAAW,MAAM;IACtB,qEAAqE;IACrE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC/C,yDAAyD;IACzD,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;CACnC;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,MAAM;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAE7C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAK3C,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;CAGrC;AAED;;;;;GAKG;AACH,qBAAa,YAAa,YAAW,MAAM;IAEzC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAHZ,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,cAAc,EAC1B,KAAK,EAAE,MAAM,EACb,YAAY,GAAE,MAAe;IAGzC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAU3C,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;CASrC"}
|
package/dist/signer.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BSM, } from '@bsv/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Signer adapter for a raw PrivateKey.
|
|
4
|
+
*/
|
|
5
|
+
export class PrivateKeySigner {
|
|
6
|
+
privateKey;
|
|
7
|
+
constructor(privateKey) {
|
|
8
|
+
this.privateKey = privateKey;
|
|
9
|
+
}
|
|
10
|
+
async signHash(hash) {
|
|
11
|
+
const sig = BSM.sign(hash, this.privateKey, 'raw');
|
|
12
|
+
return sig.toDER();
|
|
13
|
+
}
|
|
14
|
+
async getPublicKey() {
|
|
15
|
+
return this.privateKey.toPublicKey().toString();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Signer adapter for a BRC-100 WalletInterface.
|
|
20
|
+
*
|
|
21
|
+
* Uses wallet.createSignature with hashToDirectlySign and
|
|
22
|
+
* wallet.getPublicKey for key derivation via protocolID/keyID.
|
|
23
|
+
*/
|
|
24
|
+
export class WalletSigner {
|
|
25
|
+
wallet;
|
|
26
|
+
protocolID;
|
|
27
|
+
keyID;
|
|
28
|
+
counterparty;
|
|
29
|
+
constructor(wallet, protocolID, keyID, counterparty = 'self') {
|
|
30
|
+
this.wallet = wallet;
|
|
31
|
+
this.protocolID = protocolID;
|
|
32
|
+
this.keyID = keyID;
|
|
33
|
+
this.counterparty = counterparty;
|
|
34
|
+
}
|
|
35
|
+
async signHash(hash) {
|
|
36
|
+
const { signature } = await this.wallet.createSignature({
|
|
37
|
+
protocolID: this.protocolID,
|
|
38
|
+
keyID: this.keyID,
|
|
39
|
+
counterparty: this.counterparty,
|
|
40
|
+
hashToDirectlySign: hash,
|
|
41
|
+
});
|
|
42
|
+
return Array.from(signature);
|
|
43
|
+
}
|
|
44
|
+
async getPublicKey() {
|
|
45
|
+
const { publicKey } = await this.wallet.getPublicKey({
|
|
46
|
+
protocolID: this.protocolID,
|
|
47
|
+
keyID: this.keyID,
|
|
48
|
+
counterparty: this.counterparty,
|
|
49
|
+
forSelf: true,
|
|
50
|
+
});
|
|
51
|
+
return publicKey;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=signer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,GAAG,GAKH,MAAM,UAAU,CAAA;AAgBjB;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACC;IAA7B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD,KAAK,CAAC,QAAQ,CAAC,IAAc;QAC5B,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,CAAc,CAAA;QAC/D,OAAO,GAAG,CAAC,KAAK,EAAc,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,YAAY;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAA;IAChD,CAAC;CACD;AAED;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAEN;IACA;IACA;IACA;IAJlB,YACkB,MAAuB,EACvB,UAA0B,EAC1B,KAAa,EACb,eAAuB,MAAM;QAH7B,WAAM,GAAN,MAAM,CAAiB;QACvB,eAAU,GAAV,UAAU,CAAgB;QAC1B,UAAK,GAAL,KAAK,CAAQ;QACb,iBAAY,GAAZ,YAAY,CAAiB;IAC5C,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAC,IAAc;QAC5B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;YACvD,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,kBAAkB,EAAE,IAAI;SACxB,CAAC,CAAA;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,YAAY;QACjB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YACpD,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,OAAO,EAAE,IAAI;SACb,CAAC,CAAA;QACF,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@1sat/templates",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Bitcoin script templates for 1Sat Ordinals SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./sigma": {
|
|
14
|
+
"types": "./dist/bitcom/sigma.d.ts",
|
|
15
|
+
"import": "./dist/bitcom/sigma.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": ["dist"],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"dev": "tsc --watch",
|
|
22
|
+
"clean": "rm -rf dist"
|
|
23
|
+
},
|
|
24
|
+
"keywords": ["1sat", "bsv", "ordinals", "templates", "typescript"],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@1sat/types": "0.0.13"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@bsv/sdk": "^2.0.4",
|
|
31
|
+
"sigma-protocol": "^0.1.9"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"sigma-protocol": {
|
|
35
|
+
"optional": true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@bsv/sdk": "^2.0.4",
|
|
40
|
+
"sigma-protocol": "^0.1.9",
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
|
+
}
|
|
43
|
+
}
|