@gobob/bob-sdk 1.1.0 → 1.2.0

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/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # BOB SDK
2
+
3
+ The BOB SDK helps you interact with BOB and Bitcoin, including Ordinals, BRC20, Runes, and more.
4
+
5
+ ## Learn more
6
+
7
+ - [Website](https://www.gobob.xyz/)
8
+ - [Docs](https://docs.gobob.xyz/)
9
+
10
+ ## Installation
11
+
12
+ ```shell
13
+ pnpm i @bob-sdk/sdk
14
+ ```
15
+
16
+ ## Test
17
+
18
+ ```shell
19
+ pnpm test
20
+ ```
21
+
22
+ ## Contributing
23
+
24
+ BOB is an open-source project. We welcome contributions of all sorts. There are many ways to help, from reporting issues, contributing code, and helping us improve our community.
package/dist/electrs.d.ts CHANGED
@@ -6,19 +6,93 @@ export interface MerkleProof {
6
6
  merkle: string;
7
7
  pos: number;
8
8
  }
9
+ export interface UTXO {
10
+ txid: string;
11
+ vout: number;
12
+ value: number;
13
+ confirmed: boolean;
14
+ height?: number;
15
+ }
16
+ export interface Transaction {
17
+ txid: string;
18
+ version: number;
19
+ locktime: number;
20
+ size: number;
21
+ weight: number;
22
+ fee: number;
23
+ vin: Array<{
24
+ txid: string;
25
+ vout: number;
26
+ is_coinbase: boolean;
27
+ scriptsig: string;
28
+ scriptsig_asm: string;
29
+ inner_redeemscript_asm?: string;
30
+ inner_witnessscript_asm?: string;
31
+ sequence?: number;
32
+ witness?: string[];
33
+ prevout: {
34
+ scriptpubkey: string;
35
+ scriptpubkey_asm: string;
36
+ scriptpubkey_type: string;
37
+ scriptpubkey_address: string;
38
+ value: number;
39
+ } | null;
40
+ }>;
41
+ vout: Array<{
42
+ scriptpubkey: string;
43
+ scriptpubkey_asm?: string;
44
+ scriptpubkey_type?: string;
45
+ scriptpubkey_address?: string;
46
+ value: number;
47
+ }>;
48
+ status: {
49
+ confirmed: boolean;
50
+ block_height: number;
51
+ block_hash: string;
52
+ block_time: number;
53
+ };
54
+ }
55
+ export interface Block {
56
+ id: string;
57
+ height: number;
58
+ version: number;
59
+ timestamp: number;
60
+ bits: number;
61
+ nonce: number;
62
+ difficulty: number;
63
+ merkle_root: string;
64
+ tx_count: number;
65
+ size: number;
66
+ weight: number;
67
+ previousblockhash: string | null;
68
+ mediantime: number;
69
+ }
9
70
  export interface ElectrsClient {
71
+ getLatestHeight(): Promise<number>;
72
+ getBlock(hash: string): Promise<Block>;
10
73
  getBlockHash(height: number): Promise<string>;
11
74
  getBlockHeader(hash: string): Promise<string>;
75
+ getTransaction(txId: string): Promise<Transaction>;
12
76
  getTransactionHex(txId: string): Promise<string>;
13
77
  getMerkleProof(txId: string): Promise<MerkleProof>;
78
+ getFeeEstimate(confirmationTarget: number): Promise<number>;
79
+ getAddressUtxos(address: string): Promise<Array<UTXO>>;
80
+ broadcastTx(txHex: string): Promise<string>;
14
81
  }
15
82
  export declare class DefaultElectrsClient implements ElectrsClient {
16
83
  private basePath;
17
84
  constructor(networkOrUrl?: string);
85
+ getLatestHeight(): Promise<number>;
86
+ getBlock(blockHash: string): Promise<Block>;
18
87
  getBlockHash(height: number): Promise<string>;
19
88
  getBlockHeader(hash: string): Promise<string>;
89
+ getBlockHeaderAt(height: number): Promise<string>;
90
+ getTransaction(txId: string): Promise<Transaction>;
20
91
  getTransactionHex(txId: string): Promise<string>;
21
92
  getMerkleProof(txId: string): Promise<MerkleProof>;
93
+ getFeeEstimate(confirmationTarget: number): Promise<number>;
94
+ getAddressUtxos(address: string, confirmed?: boolean): Promise<Array<UTXO>>;
95
+ broadcastTx(txHex: string): Promise<string>;
22
96
  getJson<T>(url: string): Promise<T>;
23
97
  getText(url: string): Promise<string>;
24
98
  }
package/dist/electrs.js CHANGED
@@ -23,12 +23,25 @@ class DefaultElectrsClient {
23
23
  this.basePath = networkOrUrl;
24
24
  }
25
25
  }
26
+ async getLatestHeight() {
27
+ return parseInt(await this.getText(`${this.basePath}/blocks/tip/height`), 10);
28
+ }
29
+ async getBlock(blockHash) {
30
+ return this.getJson(`${this.basePath}/block/${blockHash}`);
31
+ }
26
32
  async getBlockHash(height) {
27
33
  return this.getText(`${this.basePath}/block-height/${height}`);
28
34
  }
29
35
  async getBlockHeader(hash) {
30
36
  return this.getText(`${this.basePath}/block/${hash}/header`);
31
37
  }
38
+ async getBlockHeaderAt(height) {
39
+ const blockHash = await this.getBlockHash(height);
40
+ return await this.getBlockHeader(blockHash);
41
+ }
42
+ async getTransaction(txId) {
43
+ return this.getJson(`${this.basePath}/tx/${txId}`);
44
+ }
32
45
  async getTransactionHex(txId) {
33
46
  return this.getText(`${this.basePath}/tx/${txId}/hex`);
34
47
  }
@@ -40,6 +53,31 @@ class DefaultElectrsClient {
40
53
  pos: response.pos,
41
54
  };
42
55
  }
56
+ async getFeeEstimate(confirmationTarget) {
57
+ const response = await this.getJson(`${this.basePath}/fee-estimates`);
58
+ return response[confirmationTarget];
59
+ }
60
+ async getAddressUtxos(address, confirmed) {
61
+ const response = await this.getJson(`${this.basePath}/address/${address}/utxo`);
62
+ return response
63
+ .filter(utxo => (typeof confirmed !== "undefined") ? confirmed === utxo.status.confirmed : true)
64
+ .map(utxo => {
65
+ return {
66
+ txid: utxo.txid,
67
+ vout: utxo.vout,
68
+ value: utxo.value,
69
+ confirmed: utxo.status.confirmed,
70
+ height: utxo.status.block_height
71
+ };
72
+ });
73
+ }
74
+ async broadcastTx(txHex) {
75
+ const res = await fetch(`${this.basePath}/tx`, {
76
+ method: 'POST',
77
+ body: txHex
78
+ });
79
+ return await res.text();
80
+ }
43
81
  async getJson(url) {
44
82
  const response = await fetch(url);
45
83
  if (!response.ok) {
@@ -1 +1 @@
1
- {"version":3,"file":"electrs.js","sourceRoot":"","sources":["../src/electrs.ts"],"names":[],"mappings":";;;AAIa,QAAA,yBAAyB,GAAG,+BAA+B,CAAC;AAK5D,QAAA,yBAAyB,GAAG,+BAA+B,CAAC;AAK5D,QAAA,yBAAyB,GAAG,u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AAY;aACnC,CAAA;QACL,CAAC,CAAC,CAAC;IACX,CAAC;IAKD,KAAK,CAAC,WAAW,CAAC,KAAa;QAC3B,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,QAAQ,KAAK,EAAE;YAC3C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,KAAK;SACd,CAAC,CAAC;QACH,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAKD,KAAK,CAAC,OAAO,CAAI,GAAW;QACxB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAgB,CAAC;IAC/C,CAAC;IAKD,KAAK,CAAC,OAAO,CAAC,GAAW;QACrB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;CACJ;AAtKD,oDAsKC"}
@@ -0,0 +1,3 @@
1
+ import { ElectrsClient } from "./electrs";
2
+ import { OrdinalsClient } from "./ordinal-api";
3
+ export declare function getInscriptionIds(electrsClient: ElectrsClient, ordinalsClient: OrdinalsClient, bitcoinAddress: string): Promise<string[]>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getInscriptionIds = void 0;
27
+ const inscription_1 = require("./inscription");
28
+ const ordinal_api_1 = require("./ordinal-api");
29
+ const bitcoin = __importStar(require("bitcoinjs-lib"));
30
+ async function getInscriptionIds(electrsClient, ordinalsClient, bitcoinAddress) {
31
+ const utxos = await electrsClient.getAddressUtxos(bitcoinAddress);
32
+ const inscriptionIds = await Promise.all(utxos.sort((a, b) => {
33
+ const heightA = a.height || Number.MAX_SAFE_INTEGER;
34
+ const heightB = b.height || Number.MAX_SAFE_INTEGER;
35
+ return heightA - heightB;
36
+ }).map(utxo => getInscriptionIdsForUtxo(electrsClient, ordinalsClient, utxo)));
37
+ return inscriptionIds.flat();
38
+ }
39
+ exports.getInscriptionIds = getInscriptionIds;
40
+ async function getInscriptionIdsForUtxo(electrsClient, ordinalsClient, utxo) {
41
+ if (utxo.confirmed) {
42
+ const outputJson = await ordinalsClient.getInscriptionsFromOutPoint(utxo);
43
+ return outputJson.inscriptions;
44
+ }
45
+ const txHex = await electrsClient.getTransactionHex(utxo.txid);
46
+ const tx = bitcoin.Transaction.fromHex(txHex);
47
+ if (utxo.vout == 0) {
48
+ const parentInscriptions = await Promise.all(tx.ins.map(async (txInput) => {
49
+ const txid = txInput.hash.reverse().toString("hex");
50
+ const outputJson = await ordinalsClient.getInscriptionsFromOutPoint({ txid, vout: txInput.index });
51
+ return outputJson.inscriptions;
52
+ }));
53
+ const inscriptionIds = parentInscriptions.flat();
54
+ if (inscriptionIds.length > 0) {
55
+ return inscriptionIds;
56
+ }
57
+ }
58
+ const inscriptions = (0, inscription_1.parseInscriptions)(tx);
59
+ if (utxo.vout != 0) {
60
+ return [];
61
+ }
62
+ else {
63
+ return inscriptions.map((_, index) => ordinal_api_1.InscriptionId.toString({ txid: utxo.txid, index }));
64
+ }
65
+ }
66
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAkD;AAClD,+CAA8D;AAC9D,uDAAyC;AAGlC,KAAK,UAAU,iBAAiB,CAAC,aAA4B,EAAE,cAA8B,EAAE,cAAsB;IACxH,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAClE,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CACpC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAEhB,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,gBAAgB,CAAC;QACpD,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,gBAAgB,CAAC;QAEpD,OAAO,OAAO,GAAG,OAAO,CAAC;IAC7B,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,wBAAwB,CAAC,aAAa,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC,CAChF,CAAC;IACF,OAAO,cAAc,CAAC,IAAI,EAAE,CAAC;AACjC,CAAC;AAZD,8CAYC;AAGD,KAAK,UAAU,wBAAwB,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AE,CAAC,2BAAa,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC9F,CAAC;AACL,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export * from "./electrs";
2
2
  export * from "./relay";
3
3
  export * from "./utils";
4
+ export * from "./ordinals";
5
+ export * from "./helpers";
package/dist/index.js CHANGED
@@ -17,4 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./electrs"), exports);
18
18
  __exportStar(require("./relay"), exports);
19
19
  __exportStar(require("./utils"), exports);
20
+ __exportStar(require("./ordinals"), exports);
21
+ __exportStar(require("./helpers"), exports);
20
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB;AACxB,6CAA2B;AAC3B,4CAA0B"}
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ import * as bitcoin from "bitcoinjs-lib";
3
+ import { ElectrsClient } from "./electrs";
4
+ export declare const PROTOCOL_ID: Buffer;
5
+ export declare const MAX_CHUNK_SIZE = 520;
6
+ export declare function chunkContent(data: Buffer): Buffer[];
7
+ export declare class Inscription {
8
+ tags: Map<number, Buffer>;
9
+ body: Buffer;
10
+ constructor(tags?: Map<number, Buffer>, body?: Buffer);
11
+ getContentType(): string | null;
12
+ getContentEncoding(): string | null;
13
+ setContentType(contentType: string): void;
14
+ setContentEncoding(contentEncoding: string): void;
15
+ private getTags;
16
+ toScript(xOnlyPublicKey: Buffer): (number | Buffer)[];
17
+ }
18
+ export declare namespace Inscription {
19
+ function createTextInscription(text: string): Inscription;
20
+ function createInscription(contentType: string, content: Buffer): Inscription;
21
+ }
22
+ export declare function parseInscriptions(tx: bitcoin.Transaction): Inscription[];
23
+ export declare function getTxInscriptions(electrsClient: ElectrsClient, txid: string): Promise<Inscription[]>;
24
+ export declare function getInscriptionFromId(electrsClient: ElectrsClient, inscriptionId: string): Promise<Inscription>;
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getInscriptionFromId = exports.getTxInscriptions = exports.parseInscriptions = exports.Inscription = exports.chunkContent = exports.MAX_CHUNK_SIZE = exports.PROTOCOL_ID = void 0;
27
+ const bitcoin = __importStar(require("bitcoinjs-lib"));
28
+ const ordinal_api_1 = require("./ordinal-api");
29
+ const textEncoder = new TextEncoder();
30
+ const OP_INT_BASE = bitcoin.opcodes.OP_RESERVED;
31
+ const TAPROOT_ANNEX_PREFIX = 0x50;
32
+ exports.PROTOCOL_ID = Buffer.from("6f7264", "hex");
33
+ const CONTENT_TYPE_TAG = bitcoin.opcodes.OP_1;
34
+ const CONTENT_ENCODING_TAG = bitcoin.opcodes.OP_9;
35
+ exports.MAX_CHUNK_SIZE = 520;
36
+ function chunkContent(data) {
37
+ const body = [];
38
+ let start = 0;
39
+ while (start < data.length) {
40
+ body.push(data.subarray(start, start + exports.MAX_CHUNK_SIZE));
41
+ start += exports.MAX_CHUNK_SIZE;
42
+ }
43
+ return body;
44
+ }
45
+ exports.chunkContent = chunkContent;
46
+ function convertOpInt(value) {
47
+ if (value >= bitcoin.opcodes.OP_1 && value <= bitcoin.opcodes.OP_16) {
48
+ return value - OP_INT_BASE;
49
+ }
50
+ return value;
51
+ }
52
+ class Inscription {
53
+ constructor(tags, body) {
54
+ this.tags = tags ?? new Map();
55
+ this.body = body;
56
+ }
57
+ getContentType() {
58
+ const data = this.tags[CONTENT_TYPE_TAG];
59
+ if (Buffer.isBuffer(data)) {
60
+ return data.toString("utf-8");
61
+ }
62
+ return null;
63
+ }
64
+ getContentEncoding() {
65
+ const data = this.tags[CONTENT_ENCODING_TAG];
66
+ if (Buffer.isBuffer(data)) {
67
+ return data.toString("utf-8");
68
+ }
69
+ return null;
70
+ }
71
+ setContentType(contentType) {
72
+ this.tags[CONTENT_TYPE_TAG] = Buffer.from(textEncoder.encode(contentType));
73
+ }
74
+ setContentEncoding(contentEncoding) {
75
+ this.tags[CONTENT_ENCODING_TAG] = Buffer.from(textEncoder.encode(contentEncoding));
76
+ }
77
+ getTags() {
78
+ const tags = this.tags;
79
+ return Object.keys(this.tags).map(function (key) {
80
+ return [convertOpInt(Number(key)), tags[key]];
81
+ });
82
+ }
83
+ toScript(xOnlyPublicKey) {
84
+ return [
85
+ xOnlyPublicKey,
86
+ bitcoin.opcodes.OP_CHECKSIG,
87
+ bitcoin.opcodes.OP_0,
88
+ bitcoin.opcodes.OP_IF,
89
+ exports.PROTOCOL_ID,
90
+ ...this.getTags().map(([key, value]) => [
91
+ 1,
92
+ key,
93
+ value,
94
+ ]).flat(),
95
+ bitcoin.opcodes.OP_0,
96
+ ...chunkContent(this.body),
97
+ bitcoin.opcodes.OP_ENDIF,
98
+ ];
99
+ }
100
+ }
101
+ exports.Inscription = Inscription;
102
+ (function (Inscription) {
103
+ function createTextInscription(text) {
104
+ return Inscription.createInscription("text/plain;charset=utf-8", Buffer.from(textEncoder.encode(text)));
105
+ }
106
+ Inscription.createTextInscription = createTextInscription;
107
+ function createInscription(contentType, content) {
108
+ const inscription = new Inscription;
109
+ inscription.setContentType(contentType),
110
+ inscription.body = content;
111
+ return inscription;
112
+ }
113
+ Inscription.createInscription = createInscription;
114
+ })(Inscription || (exports.Inscription = Inscription = {}));
115
+ function getTapscript(witness) {
116
+ const len = witness.length;
117
+ const last = witness[len - 1];
118
+ if (typeof last === 'undefined') {
119
+ return null;
120
+ }
121
+ let scriptPosFromLast = 2;
122
+ if (len >= 2 && last[0] == TAPROOT_ANNEX_PREFIX) {
123
+ scriptPosFromLast = 3;
124
+ }
125
+ if (typeof witness[len - scriptPosFromLast] === 'undefined') {
126
+ return null;
127
+ }
128
+ return bitcoin.script.decompile(witness[len - scriptPosFromLast]);
129
+ }
130
+ function parseInscriptions(tx) {
131
+ let inscriptions = [];
132
+ for (const txInput of tx.ins) {
133
+ const tapscript = getTapscript(txInput.witness);
134
+ if (tapscript == null) {
135
+ continue;
136
+ }
137
+ const chunks = tapscript.values();
138
+ for (let chunk = chunks.next(); !chunk.done; chunk = chunks.next()) {
139
+ if (chunk.value != bitcoin.opcodes.OP_FALSE) {
140
+ continue;
141
+ }
142
+ if (chunks.next().value != bitcoin.opcodes.OP_IF) {
143
+ continue;
144
+ }
145
+ const data = chunks.next().value;
146
+ if (!Buffer.isBuffer(data) && !data.equals(exports.PROTOCOL_ID)) {
147
+ continue;
148
+ }
149
+ let tags = new Map();
150
+ let body = [];
151
+ let isBody = false;
152
+ for (let chunk = chunks.next(); !chunk.done; chunk = chunks.next()) {
153
+ if (chunk.value == bitcoin.opcodes.OP_ENDIF) {
154
+ inscriptions.push(new Inscription(tags, Buffer.concat(body)));
155
+ break;
156
+ }
157
+ else if (chunk.value == bitcoin.opcodes.OP_0) {
158
+ isBody = true;
159
+ continue;
160
+ }
161
+ if (!isBody) {
162
+ const data = chunks.next().value;
163
+ if (typeof chunk.value == 'number' && Buffer.isBuffer(data)) {
164
+ tags[chunk.value] = data;
165
+ }
166
+ }
167
+ else if (Buffer.isBuffer(chunk.value)) {
168
+ body.push(chunk.value);
169
+ }
170
+ }
171
+ }
172
+ }
173
+ return inscriptions;
174
+ }
175
+ exports.parseInscriptions = parseInscriptions;
176
+ async function getTxInscriptions(electrsClient, txid) {
177
+ const txHex = await electrsClient.getTransactionHex(txid);
178
+ const tx = bitcoin.Transaction.fromHex(txHex);
179
+ return parseInscriptions(tx);
180
+ }
181
+ exports.getTxInscriptions = getTxInscriptions;
182
+ async function getInscriptionFromId(electrsClient, inscriptionId) {
183
+ const { txid, index } = ordinal_api_1.InscriptionId.fromString(inscriptionId);
184
+ const inscriptions = await getTxInscriptions(electrsClient, txid);
185
+ return inscriptions[index];
186
+ }
187
+ exports.getInscriptionFromId = getInscriptionFromId;
188
+ //# sourceMappingURL=inscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inscription.js","sourceRoot":"","sources":["../src/inscription.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAyC;AAEzC,+CAA8C;AAE9C,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;AAGhD,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAGrB,QAAA,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAExD,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;A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C,KAAK,CAAC,CAAC;AAC/B,CAAC;AAJD,oDAIC"}
@@ -0,0 +1,98 @@
1
+ export declare const REGTEST_ORD_BASE_PATH = "http://0.0.0.0:3003";
2
+ export declare const MAINNET_ORD_BASE_PATH = "https://ordinals-mainnet.gobob.xyz";
3
+ export declare const TESTNET_ORD_BASE_PATH = "https://ordinals-testnet.gobob.xyz";
4
+ export type InscriptionId = {
5
+ txid: string;
6
+ index: number;
7
+ };
8
+ export declare namespace InscriptionId {
9
+ function toString(id: InscriptionId): string;
10
+ function fromString(id: string): InscriptionId;
11
+ }
12
+ export type OutPoint = {
13
+ txid: string;
14
+ vout: number;
15
+ };
16
+ export declare namespace OutPoint {
17
+ function toString(id: OutPoint): string;
18
+ function fromString(id: string): OutPoint;
19
+ }
20
+ export type SatPoint = {
21
+ outpoint: OutPoint;
22
+ offset: number;
23
+ };
24
+ export declare namespace SatPoint {
25
+ function toString(id: SatPoint): string;
26
+ function fromString(id: string): SatPoint;
27
+ }
28
+ export interface InscriptionsJson<InscriptionId> {
29
+ ids: InscriptionId[];
30
+ more: boolean;
31
+ page_index: number;
32
+ }
33
+ export interface OutputJson {
34
+ address: string | null;
35
+ indexed: boolean;
36
+ inscriptions: string[];
37
+ runes: [string, number][];
38
+ sat_ranges: string | null;
39
+ script_pubkey: string;
40
+ spent: boolean;
41
+ transaction: string;
42
+ value: number;
43
+ }
44
+ export interface SatJson<InscriptionId> {
45
+ number: number;
46
+ decimal: string;
47
+ degree: string;
48
+ name: string;
49
+ block: number;
50
+ cycle: number;
51
+ epoch: number;
52
+ period: number;
53
+ offset: number;
54
+ rarity: string;
55
+ percentile: string;
56
+ satpoint: string | null;
57
+ timestamp: number;
58
+ inscriptions: InscriptionId[];
59
+ }
60
+ export interface InscriptionJson<InscriptionId, SatPoint> {
61
+ address: string | null;
62
+ charms: string[];
63
+ children: InscriptionId[];
64
+ content_length: number | null;
65
+ content_type: string | null;
66
+ fee: number;
67
+ height: number;
68
+ id: InscriptionId;
69
+ next: InscriptionId | null;
70
+ number: number;
71
+ parent: InscriptionId | null;
72
+ previous: InscriptionId | null;
73
+ rune: string | null;
74
+ sat: string | null;
75
+ satpoint: SatPoint;
76
+ timestamp: number;
77
+ value: number | null;
78
+ }
79
+ export interface OrdinalsClient {
80
+ getInscriptionFromId(id: InscriptionId): Promise<InscriptionJson<InscriptionId, SatPoint>>;
81
+ getInscriptions(): Promise<InscriptionsJson<InscriptionId>>;
82
+ getInscriptionsFromBlock(height: number): Promise<InscriptionsJson<InscriptionId>>;
83
+ getInscriptionsFromOutPoint(outPoint: OutPoint): Promise<OutputJson>;
84
+ getInscriptionsFromSat(sat: number): Promise<SatJson<InscriptionId>>;
85
+ getInscriptionsFromStartBlock(startHeight: number): Promise<InscriptionsJson<InscriptionId>>;
86
+ }
87
+ export declare class DefaultOrdinalsClient implements OrdinalsClient {
88
+ private basePath;
89
+ constructor(networkOrUrl?: string);
90
+ getInscriptionFromId(id: InscriptionId): Promise<InscriptionJson<InscriptionId, SatPoint>>;
91
+ getInscriptions(): Promise<InscriptionsJson<InscriptionId>>;
92
+ getInscriptionsFromBlock(height: number): Promise<InscriptionsJson<InscriptionId>>;
93
+ getInscriptionsFromOutPoint(outPoint: OutPoint): Promise<OutputJson>;
94
+ getInscriptionsFromSat(sat: number): Promise<SatJson<InscriptionId>>;
95
+ getInscriptionsFromStartBlock(startHeight: number): Promise<InscriptionsJson<InscriptionId>>;
96
+ getJson<T>(url: string): Promise<T>;
97
+ parseInscriptionsJson(inscriptionsJson: InscriptionsJson<string>): InscriptionsJson<InscriptionId>;
98
+ }
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultOrdinalsClient = exports.SatPoint = exports.OutPoint = exports.InscriptionId = exports.TESTNET_ORD_BASE_PATH = exports.MAINNET_ORD_BASE_PATH = exports.REGTEST_ORD_BASE_PATH = void 0;
4
+ exports.REGTEST_ORD_BASE_PATH = "http://0.0.0.0:3003";
5
+ exports.MAINNET_ORD_BASE_PATH = "https://ordinals-mainnet.gobob.xyz";
6
+ exports.TESTNET_ORD_BASE_PATH = "https://ordinals-testnet.gobob.xyz";
7
+ var InscriptionId;
8
+ (function (InscriptionId) {
9
+ function toString(id) {
10
+ return `${id.txid}i${id.index}`;
11
+ }
12
+ InscriptionId.toString = toString;
13
+ function fromString(id) {
14
+ const [txid, index] = id.split("i");
15
+ return {
16
+ txid,
17
+ index: parseInt(index, 10),
18
+ };
19
+ }
20
+ InscriptionId.fromString = fromString;
21
+ })(InscriptionId || (exports.InscriptionId = InscriptionId = {}));
22
+ var OutPoint;
23
+ (function (OutPoint) {
24
+ function toString(id) {
25
+ return `${id.txid}:${id.vout}`;
26
+ }
27
+ OutPoint.toString = toString;
28
+ function fromString(id) {
29
+ const [txid, vout] = id.split(":");
30
+ return {
31
+ txid,
32
+ vout: parseInt(vout, 10),
33
+ };
34
+ }
35
+ OutPoint.fromString = fromString;
36
+ })(OutPoint || (exports.OutPoint = OutPoint = {}));
37
+ var SatPoint;
38
+ (function (SatPoint) {
39
+ function toString(id) {
40
+ return `${OutPoint.toString(id.outpoint)}:${id.offset}`;
41
+ }
42
+ SatPoint.toString = toString;
43
+ function fromString(id) {
44
+ const [txid, vout, offset] = id.split(":");
45
+ return {
46
+ outpoint: {
47
+ txid,
48
+ vout: parseInt(vout, 10),
49
+ },
50
+ offset: parseInt(offset, 10),
51
+ };
52
+ }
53
+ SatPoint.fromString = fromString;
54
+ })(SatPoint || (exports.SatPoint = SatPoint = {}));
55
+ class DefaultOrdinalsClient {
56
+ constructor(networkOrUrl = "mainnet") {
57
+ switch (networkOrUrl) {
58
+ case "mainnet":
59
+ this.basePath = exports.MAINNET_ORD_BASE_PATH;
60
+ break;
61
+ case "testnet":
62
+ this.basePath = exports.TESTNET_ORD_BASE_PATH;
63
+ break;
64
+ case "regtest":
65
+ this.basePath = exports.REGTEST_ORD_BASE_PATH;
66
+ break;
67
+ default:
68
+ this.basePath = networkOrUrl;
69
+ }
70
+ }
71
+ async getInscriptionFromId(id) {
72
+ const inscriptionJson = await this.getJson(`${this.basePath}/inscription/${InscriptionId.toString(id)}`);
73
+ return {
74
+ ...inscriptionJson,
75
+ children: inscriptionJson.children.map(InscriptionId.fromString),
76
+ id: InscriptionId.fromString(inscriptionJson.id),
77
+ next: (inscriptionJson.next != null) ? InscriptionId.fromString(inscriptionJson.next) : null,
78
+ parent: (inscriptionJson.parent != null) ? InscriptionId.fromString(inscriptionJson.parent) : null,
79
+ previous: (inscriptionJson.previous != null) ? InscriptionId.fromString(inscriptionJson.previous) : null,
80
+ satpoint: SatPoint.fromString(inscriptionJson.satpoint),
81
+ };
82
+ }
83
+ async getInscriptions() {
84
+ const inscriptionsJson = await this.getJson(`${this.basePath}/inscriptions`);
85
+ return this.parseInscriptionsJson(inscriptionsJson);
86
+ }
87
+ async getInscriptionsFromBlock(height) {
88
+ const inscriptionsJson = await this.getJson(`${this.basePath}/inscriptions/block/${height}`);
89
+ return this.parseInscriptionsJson(inscriptionsJson);
90
+ }
91
+ async getInscriptionsFromOutPoint(outPoint) {
92
+ return await this.getJson(`${this.basePath}/output/${OutPoint.toString(outPoint)}`);
93
+ }
94
+ async getInscriptionsFromSat(sat) {
95
+ const satJson = await this.getJson(`${this.basePath}/sat/${sat}`);
96
+ return {
97
+ ...satJson,
98
+ inscriptions: satJson.inscriptions.map(id => InscriptionId.fromString(id)),
99
+ };
100
+ }
101
+ async getInscriptionsFromStartBlock(startHeight) {
102
+ const inscriptionsJson = await this.getJson(`${this.basePath}/inscriptions/${startHeight}`);
103
+ return this.parseInscriptionsJson(inscriptionsJson);
104
+ }
105
+ async getJson(url) {
106
+ const response = await fetch(url, {
107
+ headers: {
108
+ 'Accept': 'application/json',
109
+ },
110
+ });
111
+ if (!response.ok) {
112
+ throw new Error(response.statusText);
113
+ }
114
+ return await response.json();
115
+ }
116
+ parseInscriptionsJson(inscriptionsJson) {
117
+ const ids = inscriptionsJson.ids.map(id => InscriptionId.fromString(id));
118
+ return {
119
+ ...inscriptionsJson,
120
+ ids,
121
+ };
122
+ }
123
+ }
124
+ exports.DefaultOrdinalsClient = DefaultOrdinalsClient;
125
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ordinal-api/index.ts"],"names":[],"mappings":";;;AAIa,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAM9C,QAAA,qBAAqB,GAAG,oCAAoC,CAAC;AAM7D,QAAA,qBAAqB,GAAG,oCAAoC,CAAC;AAQ1E,IAAc,aAAa,CAa1B;AAbD,WAAc,aAAa;IACvB,SAAgB,QAAQ,CAAC,EAAiB;QACtC,OAAO,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;IAFe,sBAAQ,WAEvB,CAAA;IAED,SAAgB,UAAU,CAAC,EAAU;QAEjC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO;YACH,IAAI;YACJ,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;SAC7B,CAAC;IACN,CAAC;IAPe,wBAAU,aAOzB,CAAA;AACL,CAAC,EAba,aAAa,6BAAb,aAAa,QAa1B;AAQD,IAAc,QAAQ,CAarB;AAbD,WAAc,QAAQ;IAClB,SAAgB,QAAQ,CAAC,EAAY;QACjC,OAAO,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IAFe,iBAAQ,WAEvB,CAAA;IAED,SAAgB,UAAU,CAAC,EAAU;QAEjC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO;YACH,IAAI;YACJ,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;SAC3B,CAAC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AAG;SACN,CAAC;IACN,CAAC;CACJ;AAvGD,sDAuGC"}
@@ -1,24 +1,12 @@
1
1
  /// <reference types="node" />
2
- import * as bitcoinjsLib from "bitcoinjs-lib";
3
- interface Inscription {
4
- contentType: Buffer;
5
- content: Buffer;
6
- }
7
- export declare function createTextInscription(text: string): Inscription;
2
+ import * as bitcoin from "bitcoinjs-lib";
3
+ import { Inscription } from "../inscription";
8
4
  export interface CommitTxData {
9
- script: (number | Buffer)[];
10
- scriptTaproot: bitcoinjsLib.payments.Payment;
11
- outputScript: Buffer;
5
+ scriptTaproot: bitcoin.payments.Payment;
12
6
  tapLeafScript: {
13
7
  leafVersion: number;
14
8
  script: Buffer;
15
9
  controlBlock: Buffer;
16
10
  };
17
11
  }
18
- export declare function createCommitTxData(network: bitcoinjsLib.Network, publicKey: Buffer, inscription: Inscription): CommitTxData;
19
- export interface CommitTxResult {
20
- txId: string;
21
- sendUtxoIndex: number;
22
- sendAmount: number;
23
- }
24
- export {};
12
+ export declare function createCommitTxData(network: bitcoin.Network, publicKey: Buffer, inscription: Inscription): CommitTxData;
@@ -23,59 +23,33 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.createCommitTxData = exports.createTextInscription = void 0;
27
- const bitcoinjsLib = __importStar(require("bitcoinjs-lib"));
28
- const encoder = new TextEncoder();
26
+ exports.createCommitTxData = void 0;
27
+ const bitcoin = __importStar(require("bitcoinjs-lib"));
29
28
  function toXOnly(pubkey) {
30
29
  return pubkey.subarray(1, 33);
31
30
  }
32
- function createTextInscription(text) {
33
- const contentType = Buffer.from(encoder.encode("text/plain;charset=utf-8"));
34
- const content = Buffer.from(encoder.encode(text));
35
- return { contentType, content };
36
- }
37
- exports.createTextInscription = createTextInscription;
38
- function createInscriptionScript(xOnlyPublicKey, inscription) {
39
- const protocolId = Buffer.from(encoder.encode("ord"));
40
- return [
41
- xOnlyPublicKey,
42
- bitcoinjsLib.opcodes.OP_CHECKSIG,
43
- bitcoinjsLib.opcodes.OP_0,
44
- bitcoinjsLib.opcodes.OP_IF,
45
- protocolId,
46
- 1,
47
- 1,
48
- inscription.contentType,
49
- bitcoinjsLib.opcodes.OP_0,
50
- inscription.content,
51
- bitcoinjsLib.opcodes.OP_ENDIF,
52
- ];
53
- }
54
31
  function createCommitTxData(network, publicKey, inscription) {
55
- var _a;
56
32
  const xOnlyPublicKey = toXOnly(publicKey);
57
- const script = createInscriptionScript(xOnlyPublicKey, inscription);
58
- const outputScript = bitcoinjsLib.script.compile(script);
33
+ const script = inscription.toScript(xOnlyPublicKey);
34
+ const outputScript = bitcoin.script.compile(script);
59
35
  const scriptTree = {
60
36
  output: outputScript,
61
37
  redeemVersion: 192,
62
38
  };
63
- const scriptTaproot = bitcoinjsLib.payments.p2tr({
39
+ const scriptTaproot = bitcoin.payments.p2tr({
64
40
  internalPubkey: xOnlyPublicKey,
65
41
  scriptTree,
66
42
  redeem: scriptTree,
67
43
  network,
68
44
  });
69
- const cblock = (_a = scriptTaproot.witness) === null || _a === void 0 ? void 0 : _a[scriptTaproot.witness.length - 1];
45
+ const cblock = scriptTaproot.witness?.[scriptTaproot.witness.length - 1];
70
46
  const tapLeafScript = {
71
47
  leafVersion: scriptTaproot.redeemVersion,
72
48
  script: outputScript,
73
49
  controlBlock: cblock,
74
50
  };
75
51
  return {
76
- script,
77
52
  scriptTaproot,
78
- outputScript,
79
53
  tapLeafScript,
80
54
  };
81
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"commit.js","sourceRoot":"","sources":["../../src/ordinals/commit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA8C;AAE9C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,SAAS,OAAO,CAAC,MAAc;IAC3B,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAUD,SAAgB,qB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AAc;QACzC,MAAM,EAAE,YAAY;QACpB,YAAY,EAAE,MAAM;KACvB,CAAC;IAEF,OAAO;QACH,aAAa;QACb,aAAa;KAChB,CAAC;AACN,CAAC;AAlCD,gDAkCC"}
@@ -1,4 +1,5 @@
1
- import * as bitcoinjsLib from "bitcoinjs-lib";
1
+ import * as bitcoin from "bitcoinjs-lib";
2
2
  import { RemoteSigner } from "./signer";
3
+ import { Inscription } from "../inscription";
3
4
  export { RemoteSigner };
4
- export declare function inscribeText(signer: RemoteSigner, toAddress: string, feeRate: number, text: string, postage?: number): Promise<bitcoinjsLib.Transaction>;
5
+ export declare function inscribeData(signer: RemoteSigner, toAddress: string, feeRate: number, inscription: Inscription, postage?: number): Promise<bitcoin.Transaction>;
@@ -23,13 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.inscribeText = void 0;
27
- const bitcoinjsLib = __importStar(require("bitcoinjs-lib"));
26
+ exports.inscribeData = void 0;
27
+ const bitcoin = __importStar(require("bitcoinjs-lib"));
28
28
  const signer_1 = require("./signer");
29
29
  const commit_1 = require("./commit");
30
30
  const reveal_1 = require("./reveal");
31
31
  function estimateTxSize(network, publicKey, commitTxData, toAddress, amount) {
32
- const psbt = new bitcoinjsLib.Psbt({ network });
32
+ const psbt = new bitcoin.Psbt({ network });
33
33
  const { scriptTaproot, tapLeafScript } = commitTxData;
34
34
  psbt.addInput({
35
35
  hash: Buffer.alloc(32, 0),
@@ -49,25 +49,26 @@ function estimateTxSize(network, publicKey, commitTxData, toAddress, amount) {
49
49
  const tx = psbt.extractTransaction();
50
50
  return tx.virtualSize();
51
51
  }
52
- async function inscribeText(signer, toAddress, feeRate, text, postage = 10000) {
52
+ async function inscribeData(signer, toAddress, feeRate, inscription, postage = 10000) {
53
53
  const bitcoinNetwork = await signer.getNetwork();
54
54
  const publicKey = Buffer.from(await signer.getPublicKey(), "hex");
55
- const inscription = (0, commit_1.createTextInscription)(text);
56
55
  const commitTxData = (0, commit_1.createCommitTxData)(bitcoinNetwork, publicKey, inscription);
57
56
  const revealTxSize = estimateTxSize(bitcoinNetwork, publicKey, commitTxData, toAddress, postage);
58
57
  const revealFee = revealTxSize * feeRate;
59
58
  const commitTxAmount = revealFee + postage;
60
59
  const commitAddress = commitTxData.scriptTaproot.address;
61
60
  const commitTxId = await signer.sendToAddress(commitAddress, commitTxAmount);
62
- const commitUtxoIndex = await signer.getUtxoIndex(commitAddress, commitTxId);
61
+ const commitTx = await signer.getTransaction(commitTxId);
62
+ const scriptPubKey = bitcoin.address.toOutputScript(commitAddress, bitcoinNetwork);
63
+ const commitUtxoIndex = commitTx.outs.findIndex(out => out.script.equals(scriptPubKey));
63
64
  const commitTxResult = {
64
- txId: commitTxId,
65
- sendUtxoIndex: commitUtxoIndex,
66
- sendAmount: commitTxAmount,
65
+ tx: commitTx,
66
+ outputIndex: commitUtxoIndex,
67
+ outputAmount: commitTxAmount,
67
68
  };
68
69
  const revealPsbt = (0, reveal_1.createRevealTx)(bitcoinNetwork, commitTxData, commitTxResult, toAddress, postage);
69
70
  const revealTx = await (0, reveal_1.signRevealTx)(signer, commitTxData, revealPsbt);
70
71
  return revealTx;
71
72
  }
72
- exports.inscribeText = inscribeText;
73
+ exports.inscribeData = inscribeData;
73
74
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ordinals/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA8C;AAE9C,qCAAqD;AACrD,qCAAmF;AACnF,qCAAyE;AAOzE,SAAS,cAAc,CACrB,OAA6B,EAC7B,SAAiB,EACjB,YAA0B,EAC1B,SAAiB,EACjB,MAAc;IAEd,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAEhD,MAAM,EAAE,aAAa,EAAE,aAAa,EAA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C,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IACnF,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAExF,MAAM,cAAc,GAAG;QACrB,EAAE,EAAE,QAAQ;QACZ,WAAW,EAAE,eAAe;QAC5B,YAAY,EAAE,cAAc;KAC7B,CAAC;IAEF,MAAM,UAAU,GAAG,IAAA,uBAAc,EAC/B,cAAc,EACd,YAAY,EACZ,cAAc,EACd,SAAS,EACT,OAAO,CACR,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAY,EACjC,MAAM,EACN,YAAY,EACZ,UAAU,CACX,CAAC;IAEF,OAAO,QAAQ,CAAC;AAClB,CAAC;AA/CD,oCA+CC"}
@@ -1,9 +1,14 @@
1
1
  /// <reference types="node" />
2
- import * as bitcoinjsLib from "bitcoinjs-lib";
2
+ import * as bitcoin from "bitcoinjs-lib";
3
3
  import { RemoteSigner } from "./signer";
4
- import { CommitTxData, CommitTxResult } from "./commit";
5
- export declare function createRevealTx(network: bitcoinjsLib.Network, commitTxData: CommitTxData, commitTxResult: CommitTxResult, toAddress: string, amount: number): bitcoinjsLib.Psbt;
4
+ import { CommitTxData } from "./commit";
5
+ export interface CommitTxResult {
6
+ tx: bitcoin.Transaction;
7
+ outputIndex: number;
8
+ outputAmount: number;
9
+ }
10
+ export declare function createRevealTx(network: bitcoin.Network, commitTxData: CommitTxData, commitTxResult: CommitTxResult, toAddress: string, amount: number): bitcoin.Psbt;
6
11
  export declare const customFinalizer: (commitTxData: CommitTxData) => (inputIndex: number, input: any) => {
7
12
  finalScriptWitness: Buffer;
8
13
  };
9
- export declare function signRevealTx(signer: RemoteSigner, commitTxData: CommitTxData, psbt: bitcoinjsLib.Psbt): Promise<bitcoinjsLib.Transaction>;
14
+ export declare function signRevealTx(signer: RemoteSigner, commitTxData: CommitTxData, psbt: bitcoin.Psbt): Promise<bitcoin.Transaction>;
@@ -24,19 +24,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.signRevealTx = exports.customFinalizer = exports.createRevealTx = void 0;
27
- const bitcoinjsLib = __importStar(require("bitcoinjs-lib"));
27
+ const bitcoin = __importStar(require("bitcoinjs-lib"));
28
28
  const psbtUtils = __importStar(require("bitcoinjs-lib/src/psbt/psbtutils"));
29
29
  const { witnessStackToScriptWitness } = psbtUtils;
30
30
  function createRevealTx(network, commitTxData, commitTxResult, toAddress, amount) {
31
31
  const { scriptTaproot, tapLeafScript } = commitTxData;
32
- const psbt = new bitcoinjsLib.Psbt({ network });
32
+ const psbt = new bitcoin.Psbt({ network });
33
33
  psbt.addInput({
34
- hash: commitTxResult.txId,
35
- index: commitTxResult.sendUtxoIndex,
34
+ hash: commitTxResult.tx.getId(),
35
+ index: commitTxResult.outputIndex,
36
36
  witnessUtxo: {
37
- value: commitTxResult.sendAmount,
37
+ value: commitTxResult.outputAmount,
38
38
  script: scriptTaproot.output,
39
39
  },
40
+ nonWitnessUtxo: commitTxResult.tx.toBuffer(),
40
41
  tapLeafScript: [tapLeafScript],
41
42
  });
42
43
  psbt.addOutput({
@@ -47,10 +48,10 @@ function createRevealTx(network, commitTxData, commitTxResult, toAddress, amount
47
48
  }
48
49
  exports.createRevealTx = createRevealTx;
49
50
  const customFinalizer = (commitTxData) => {
50
- const { outputScript, tapLeafScript } = commitTxData;
51
+ const { tapLeafScript } = commitTxData;
51
52
  return (inputIndex, input) => {
52
53
  const witness = [input.tapScriptSig[inputIndex].signature]
53
- .concat(outputScript)
54
+ .concat(tapLeafScript.script)
54
55
  .concat(tapLeafScript.controlBlock);
55
56
  return {
56
57
  finalScriptWitness: witnessStackToScriptWitness(witness),
@@ -59,7 +60,7 @@ const customFinalizer = (commitTxData) => {
59
60
  };
60
61
  exports.customFinalizer = customFinalizer;
61
62
  async function signRevealTx(signer, commitTxData, psbt) {
62
- psbt = await signer.signPsbt(0, psbt);
63
+ psbt = await signer.signInput(0, psbt);
63
64
  psbt.finalizeInput(0, (0, exports.customFinalizer)(commitTxData));
64
65
  return psbt.extractTransaction();
65
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"reveal.js","sourceRoot":"","sources":["../../src/ordinals/reveal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA8C;AAC9C,4EAA8D;AAK9D,MAAM,EAAE,2BAA2B,EAAE,GAAG,SAAS,CAAC;AAKlD,SAAgB,cAAc,CAC1B,OAA6B,EAC7B,YAA0B,EAC1B,cAA8B,EAC9B,SAAiB,EACjB,MAAc;IAEd,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,YAAY,CAAC;IAEtD,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAEhD,IAAI,CAAC,QAAQ,CAAC;QACV,IAAI,EAAE,cAAc,CAAC,IAAI;QACzB,KAAK,EAAE,cAAc,CAAC,aAAa;QACnC,WAAW,EAAE;YACT,KAAK,EAAE,cAAc,CAAC,UAAU;YAChC,MAAM,EAAE,aAAa,CAAC,MAAO;SAChC;QACD,aAAa,EAAE,CAAC,aAAa,CAAC;KACjC,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,CAAC;QACX,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,SAAS;KACrB,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AAChB,CAAC;AA3BD,wCA2BC;AAEM,MAAM,eAAe,GAAG,CAAC,YAA0B,EAAE,EAAE;IAC1D,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,YAAY,CAAC;IAErD,OAAO,CAAC,UAAkB,EAAE,KAAU,EAAE,EAAE;QACtC,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC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AAE;QAC5C,aAAa,EAAE,CAAC,aAAa,CAAC;KACjC,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,CAAC;QACX,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,SAAS;KACrB,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AAChB,CAAC;AA5BD,wCA4BC;AAEM,MAAM,eAAe,GAAG,CAAC,YAA0B,EAAE,EAAE;IAC1D,MAAM,EAAE,aAAa,EAAE,GAAG,YAAY,CAAC;IAEvC,OAAO,CAAC,UAAkB,EAAE,KAAU,EAAE,EAAE;QACtC,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC;aACrD,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC;aAC5B,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QAExC,OAAO;YACH,kBAAkB,EAAE,2BAA2B,CAAC,OAAO,CAAC;SAC3D,CAAC;IACN,CAAC,CAAC;AACN,CAAC,CAAA;AAZY,QAAA,eAAe,mBAY3B;AAEM,KAAK,UAAU,YAAY,CAC9B,MAAoB,EACpB,YAA0B,EAC1B,IAAkB;IAGlB,IAAI,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAGvC,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAA,uBAAe,EAAC,YAAY,CAAC,CAAC,CAAC;IAErD,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;AACrC,CAAC;AAZD,oCAYC"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Network, Psbt, Signer } from "bitcoinjs-lib";
2
+ import { Network, Psbt, Signer, Transaction } from "bitcoinjs-lib";
3
3
  export declare class DummySigner implements Signer {
4
4
  publicKey: Buffer;
5
5
  constructor(publicKey: Buffer);
@@ -10,6 +10,6 @@ export interface RemoteSigner {
10
10
  getNetwork(): Promise<Network>;
11
11
  getPublicKey(): Promise<string>;
12
12
  sendToAddress(toAddress: string, amount: number): Promise<string>;
13
- getUtxoIndex(toAddress: string, txId: string): Promise<number>;
14
- signPsbt(inputIndex: number, psbt: Psbt): Promise<Psbt>;
13
+ getTransaction(txId: string): Promise<Transaction>;
14
+ signInput(inputIndex: number, psbt: Psbt): Promise<Psbt>;
15
15
  }
@@ -6,7 +6,7 @@ class DummySigner {
6
6
  this.publicKey = publicKey;
7
7
  }
8
8
  sign(_hash, _lowR) {
9
- return Buffer.from("304502210100000000000000000000000000000000000000000000000000000000000000000220010000000000000000000000000000000000000000000000000000000000000001", "hex");
9
+ return Buffer.alloc(64, 0);
10
10
  }
11
11
  signSchnorr(hash) {
12
12
  return Buffer.alloc(64, 0);
@@ -1 +1 @@
1
- {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/ordinals/signer.ts"],"names":[],"mappings":";;;AAKA,MAAa,WAAW;IAEpB,YAAY,SAAiB;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IACD,IAAI,CAAC,KAAa,EAAE,KAA2B;QAE3C,OAAO,MAAM,CAAC,IAAI,CAAC,kJAAkJ,EAAE,KAAK,CAAC,CAAC;IAClL,CAAC;IACD,WAAW,CAAC,IAAY;QAEpB,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC/B,CAAC;CACJ;AAbD,kCAaC;AAuCA,CAAC"}
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/ordinals/signer.ts"],"names":[],"mappings":";;;AAKA,MAAa,WAAW;IAEpB,YAAY,SAAiB;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IACD,IAAI,CAAC,KAAa,EAAE,KAA2B;QAE3C,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,WAAW,CAAC,IAAY;QAEpB,OAAO,MAAM,CAAC,KAAK,CAAC,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AM,aAAa,GAAG,yBAAyB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC5D,OAAO;QACH,GAAG,EAAE,GAAG;QAER,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QACxE,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;KAC3C,CAAC;AACN,CAAC;AAXD,wCAWC"}
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@gobob/bob-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
7
- "test": "ts-mocha test/*.ts",
7
+ "test": "vitest run test/*.ts",
8
+ "deploy-relay": "ts-node scripts/relay-genesis.ts",
9
+ "update-relay": "ts-node scripts/relay-retarget.ts",
8
10
  "build": "tsc -p tsconfig.json"
9
11
  },
10
12
  "files": [
@@ -16,16 +18,15 @@
16
18
  "README.md"
17
19
  ],
18
20
  "devDependencies": {
19
- "@types/chai": "^4.3.6",
20
- "@types/mocha": "^10.0.2",
21
- "@types/node": "^20.8.3",
22
- "chai": "^4.3.10",
21
+ "@types/node": "^20.11.25",
22
+ "@types/yargs": "^17.0.32",
23
23
  "ecpair": "^2.1.0",
24
- "mocha": "^10.2.0",
24
+ "mocha": "^10.3.0",
25
25
  "tiny-secp256k1": "^2.2.3",
26
- "ts-mocha": "^10.0.0",
27
- "ts-node-dev": "^2.0.0",
28
- "typescript": "^5.2.2"
26
+ "ts-node": "^10.0.0",
27
+ "typescript": "^5.4.2",
28
+ "vitest": "^1.3.1",
29
+ "yargs": "^17.5.1"
29
30
  },
30
31
  "dependencies": {
31
32
  "bitcoinjs-lib": "^6.1.5"