@gobob/bob-sdk 2.0.0 → 2.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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getBtcNetwork = void 0;
4
- exports.createTransfer = createTransfer;
4
+ exports.createBitcoinPsbt = createBitcoinPsbt;
5
5
  exports.getInputFromUtxoAndTx = getInputFromUtxoAndTx;
6
6
  const btc_signer_1 = require("@scure/btc-signer");
7
7
  const base_1 = require("@scure/base");
@@ -9,82 +9,95 @@ const bitcoin_address_validation_1 = require("bitcoin-address-validation");
9
9
  const esplora_1 = require("../esplora");
10
10
  const bitcoinNetworks = {
11
11
  mainnet: btc_signer_1.NETWORK,
12
- testnet: btc_signer_1.TEST_NETWORK
12
+ testnet: btc_signer_1.TEST_NETWORK,
13
13
  };
14
14
  const getBtcNetwork = (name) => {
15
15
  return bitcoinNetworks[name];
16
16
  };
17
17
  exports.getBtcNetwork = getBtcNetwork;
18
- async function createTransfer(network, addressType, fromAddress, toAddress, amount, publicKey, opReturnData, confirmationTarget = 3) {
19
- const esploraClient = new esplora_1.DefaultEsploraClient(network);
18
+ async function createBitcoinPsbt(fromAddress, toAddress, amount, publicKey, opReturnData, confirmationTarget = 3) {
19
+ const addressInfo = (0, bitcoin_address_validation_1.getAddressInfo)(fromAddress);
20
+ const network = addressInfo.network;
21
+ if (network === "regtest") {
22
+ throw new Error("Bitcoin regtest not supported");
23
+ }
24
+ if (addressInfo.type === (bitcoin_address_validation_1.AddressType.p2sh || bitcoin_address_validation_1.AddressType.p2wsh)) {
25
+ if (!publicKey) {
26
+ throw new Error("Public key is required to spend from the selected address type");
27
+ }
28
+ }
29
+ const esploraClient = new esplora_1.EsploraClient(addressInfo.network);
20
30
  const [confirmedUtxos, feeRate] = await Promise.all([
21
31
  esploraClient.getAddressUtxos(fromAddress),
22
- esploraClient.getFeeEstimate(confirmationTarget)
32
+ esploraClient.getFeeEstimate(confirmationTarget),
23
33
  ]);
24
34
  if (confirmedUtxos.length === 0) {
25
- throw new Error('No confirmed UTXOs');
35
+ throw new Error("No confirmed UTXOs");
26
36
  }
27
37
  let possibleInputs = [];
28
38
  await Promise.all(confirmedUtxos.map(async (utxo) => {
29
39
  const hex = await esploraClient.getTransactionHex(utxo.txid);
30
- const transaction = btc_signer_1.Transaction.fromRaw(Buffer.from(hex, 'hex'), { allowUnknownOutputs: true });
31
- const input = getInputFromUtxoAndTx(network, utxo, transaction, addressType, publicKey);
40
+ const transaction = btc_signer_1.Transaction.fromRaw(Buffer.from(hex, "hex"), { allowUnknownOutputs: true });
41
+ const input = getInputFromUtxoAndTx(network, utxo, transaction, addressInfo.type, publicKey);
32
42
  possibleInputs.push(input);
33
43
  }));
34
44
  const outputs = [
35
45
  {
36
46
  address: toAddress,
37
- amount: BigInt(amount)
38
- }
47
+ amount: BigInt(amount),
48
+ },
39
49
  ];
40
50
  if (opReturnData) {
41
- if (opReturnData.startsWith('0x')) {
51
+ if (opReturnData.startsWith("0x")) {
42
52
  opReturnData = opReturnData.slice(2);
43
53
  }
44
54
  outputs.push({
45
- script: btc_signer_1.Script.encode(['RETURN', base_1.hex.decode(opReturnData)]),
46
- amount: BigInt(0)
55
+ script: btc_signer_1.Script.encode(["RETURN", base_1.hex.decode(opReturnData)]),
56
+ amount: BigInt(0),
47
57
  });
48
58
  }
49
- const transaction = (0, btc_signer_1.selectUTXO)(possibleInputs, outputs, 'default', {
59
+ const transaction = (0, btc_signer_1.selectUTXO)(possibleInputs, outputs, "default", {
50
60
  changeAddress: fromAddress,
51
61
  feePerByte: BigInt(Math.ceil(feeRate)),
52
62
  bip69: true,
53
63
  createTx: true,
54
64
  network: (0, exports.getBtcNetwork)(network),
55
65
  allowUnknownOutputs: true,
56
- allowLegacyWitnessUtxo: true
66
+ allowLegacyWitnessUtxo: true,
57
67
  });
58
68
  if (!transaction || !transaction.tx) {
59
- throw new Error('Failed to create transaction. Do you have enough funds?');
69
+ throw new Error("Failed to create transaction. Do you have enough funds?");
60
70
  }
61
- return transaction.tx;
71
+ return base_1.base64.encode(transaction.tx.toPSBT(0));
62
72
  }
63
- function getInputFromUtxoAndTx(network, utxo, transaction, addressType, pubKey) {
73
+ function getInputFromUtxoAndTx(network, utxo, transaction, addressType, publicKey) {
64
74
  const output = transaction.getOutput(utxo.vout);
65
75
  let redeemScript = {};
66
76
  if (addressType === bitcoin_address_validation_1.AddressType.p2sh) {
67
- const inner = (0, btc_signer_1.p2wpkh)(Buffer.from(pubKey, 'hex'), (0, exports.getBtcNetwork)(network));
77
+ if (!publicKey) {
78
+ throw new Error("Bitcoin P2SH not supported without public key");
79
+ }
80
+ const inner = (0, btc_signer_1.p2wpkh)(Buffer.from(publicKey, "hex"), (0, exports.getBtcNetwork)(network));
68
81
  redeemScript = (0, btc_signer_1.p2sh)(inner);
69
82
  }
70
83
  const scriptMixin = {
71
- ...redeemScript
84
+ ...redeemScript,
72
85
  };
73
86
  const nonWitnessUtxo = {
74
- nonWitnessUtxo: Buffer.from(transaction.hex, 'hex')
87
+ nonWitnessUtxo: Buffer.from(transaction.hex, "hex"),
75
88
  };
76
89
  const witnessUtxo = {
77
90
  witnessUtxo: {
78
91
  script: output.script,
79
- amount: output.amount
80
- }
92
+ amount: output.amount,
93
+ },
81
94
  };
82
95
  const witnessMixin = transaction.hasWitnesses ? witnessUtxo : nonWitnessUtxo;
83
96
  const input = {
84
97
  txid: utxo.txid,
85
98
  index: utxo.vout,
86
99
  ...scriptMixin,
87
- ...witnessMixin
100
+ ...witnessMixin,
88
101
  };
89
102
  return input;
90
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utxo.js","sourceRoot":"","sources":["../../src/wallet/utxo.ts"],"names":[],"mappings":";;;AA+BA,wCA4EC;AAGD,sDAgDC;AA9JD,kDAAyG;AACzG,sCAAkC;AAClC,2EAAyD;AAEzD,wCAAwD;AAIxD,MAAM,eAAe,GAA+C;IAClE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9 +1,11 @@
1
1
  {
2
2
  "name": "@gobob/bob-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
7
+ "format:check": "prettier --check src/**/*.ts",
8
+ "format:write": "prettier --write src/**/*.ts",
7
9
  "test": "vitest run test/*.ts",
8
10
  "deploy-relay": "ts-node src/scripts/relay-genesis.ts",
9
11
  "update-relay": "ts-node src/scripts/relay-retarget.ts",
@@ -18,10 +20,12 @@
18
20
  "README.md"
19
21
  ],
20
22
  "devDependencies": {
21
- "@types/node": "^22.0.0",
23
+ "@types/node": "^22.5.0",
22
24
  "@types/yargs": "^17.0.33",
23
25
  "ecpair": "^2.1.0",
24
26
  "mocha": "^10.7.3",
27
+ "nock": "^14.0.0-beta.11",
28
+ "prettier": "3.3.3",
25
29
  "tiny-secp256k1": "^2.2.3",
26
30
  "ts-node": "^10.0.0",
27
31
  "typescript": "^5.5.4",
@@ -35,4 +39,4 @@
35
39
  "bitcoinjs-lib": "^6.1.6",
36
40
  "ethers": "^6.13.2"
37
41
  }
38
- }
42
+ }
@@ -1,2 +0,0 @@
1
- import { BitcoinNetworkName } from "./utxo";
2
- export declare const isValidBtcAddress: (network: BitcoinNetworkName, address: string) => boolean;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidBtcAddress = void 0;
4
- const BTC_MAINNET_REGEX = /\b([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[ac-hj-np-zAC-HJ-NP-Z02-9]{11,71})\b/;
5
- const BTC_TESTNET_REGEX = /\b([2mn][a-km-zA-HJ-NP-Z1-9]{25,34}|tb1[ac-hj-np-zAC-HJ-NP-Z02-9]{11,71})\b/;
6
- const mainnetRegex = new RegExp(BTC_MAINNET_REGEX);
7
- const testnetRegex = new RegExp(BTC_TESTNET_REGEX);
8
- const isValidBtcAddress = (network, address) => {
9
- switch (network) {
10
- case 'mainnet':
11
- return mainnetRegex.test(address);
12
- case 'testnet':
13
- return testnetRegex.test(address);
14
- default:
15
- throw new Error(`Invalid bitcoin network configured: ${network}. Valid values are: mainnet | testnet.`);
16
- }
17
- };
18
- exports.isValidBtcAddress = isValidBtcAddress;
19
- //# sourceMappingURL=address.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/wallet/address.ts"],"names":[],"mappings":";;;AAEA,MAAM,iBAAiB,GAAG,4EAA4E,CAAC;AACvG,MAAM,iBAAiB,GAAG,6EAA6E,CAAC;AAExG,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACnD,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAE5C,MAAM,iBAAiB,GAAG,CAAC,OAA2B,EAAE,OAAe,EAAW,EAAE;IACzF,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,SAAS;YACZ,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,KAAK,SAAS;YACZ,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC;YACE,MAAM,IAAI,KAAK,CAAC,uCAAuC,OAAO,wCAAwC,CAAC,CAAC;IAC5G,CAAC;AACH,CAAC,CAAC;AATW,QAAA,iBAAiB,qBAS5B"}