@swapkit/toolboxes 1.0.0-beta.1 → 1.0.0-beta.10

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.
@@ -160,7 +160,7 @@ async function createTransaction({
160
160
  // .inputs and .outputs will be undefined if no solution was found
161
161
  if (!(inputs && outputs)) throw new Error("Balance insufficient for transaction");
162
162
  const getNetwork = await getUtxoNetwork();
163
- const builder = new TransactionBuilder(getNetwork(chain));
163
+ const builder = new TransactionBuilder(getNetwork(chain)) as TransactionBuilderType;
164
164
 
165
165
  await Promise.all(
166
166
  inputs.map(async (utxo: UTXOType) => {
@@ -226,7 +226,7 @@ function transfer({
226
226
 
227
227
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO: refactor
228
228
  async function buildTx({ assetValue, recipient, memo, feeRate, sender }: UTXOBuildTxParams) {
229
- const { Psbt } = await import("bitcoinjs-lib");
229
+ const { Psbt } = (await import("bitcoinjs-lib")).default;
230
230
  const recipientCashAddress = toCashAddress(recipient);
231
231
  if (!bchValidateAddress(recipientCashAddress)) throw new Error("Invalid address");
232
232
 
@@ -62,8 +62,8 @@ async function addInputsAndOutputs({
62
62
  psbt.addInput({ hash: utxo.hash, index: utxo.index, ...witnessInfo, ...nonWitnessInfo });
63
63
  }
64
64
 
65
- const { initEccLib } = await import("bitcoinjs-lib");
66
- const secp256k1 = await import("@bitcoinerlab/secp256k1");
65
+ const { initEccLib } = (await import("bitcoinjs-lib")).default;
66
+ const secp256k1 = (await import("@bitcoinerlab/secp256k1")).default;
67
67
 
68
68
  for (const output of outputs) {
69
69
  const address = "address" in output && output.address ? output.address : sender;
@@ -104,7 +104,7 @@ async function createTransaction({
104
104
  }> {
105
105
  const chain = assetValue.chain as UTXOChain;
106
106
 
107
- const { Psbt } = await import("bitcoinjs-lib");
107
+ const { Psbt } = (await import("bitcoinjs-lib")).default;
108
108
  const compiledMemo = memo ? await compileMemo(memo) : null;
109
109
 
110
110
  const inputsAndOutputs = await getInputsAndTargetOutputs({
@@ -141,8 +141,8 @@ async function createTransaction({
141
141
  }
142
142
 
143
143
  export async function getUTXOAddressValidator() {
144
- const secp256k1 = await import("@bitcoinerlab/secp256k1");
145
- const { initEccLib, address: btcLibAddress } = await import("bitcoinjs-lib");
144
+ const secp256k1 = (await import("@bitcoinerlab/secp256k1")).default;
145
+ const { initEccLib, address: btcLibAddress } = (await import("bitcoinjs-lib")).default;
146
146
  const getNetwork = await getUtxoNetwork();
147
147
 
148
148
  return function validateAddress({ address, chain }: { address: string; chain: UTXOChain }) {
@@ -360,7 +360,7 @@ export async function getCreateKeysForPath<T extends keyof CreateKeysForPathRetu
360
360
  }) => CreateKeysForPathReturnType[T]
361
361
  > {
362
362
  const { ECPairFactory } = await import("ecpair");
363
- const secp256k1 = await import("@bitcoinerlab/secp256k1");
363
+ const secp256k1 = (await import("@bitcoinerlab/secp256k1")).default;
364
364
  const { HDKey } = await import("@scure/bip32");
365
365
  const { mnemonicToSeedSync } = await import("@scure/bip39");
366
366
  const getNetwork = await getUtxoNetwork();
@@ -427,7 +427,7 @@ export async function getCreateKeysForPath<T extends keyof CreateKeysForPathRetu
427
427
  }
428
428
 
429
429
  export async function addressFromKeysGetter(chain: UTXOChain) {
430
- const { payments } = await import("bitcoinjs-lib");
430
+ const { payments } = (await import("bitcoinjs-lib")).default;
431
431
  const getNetwork = await getUtxoNetwork();
432
432
 
433
433
  return function getAddressFromKeys(keys: ECPairInterface | BchECPair) {
package/src/utxo/types.ts CHANGED
@@ -52,4 +52,6 @@ export type TransactionBuilderType = {
52
52
  signatureAlgorithm?: string,
53
53
  ): void;
54
54
  build(): TransactionType;
55
+ addOutput(addressOrScriptBuffer: string | Buffer, value: number): void;
56
+ addInput(txHash: string | Buffer, vout: number, sequence?: number, prevOutScript?: Buffer): void;
55
57
  };