|
1 | 1 | import * as utxolib from "@bitgo/utxo-lib"; |
2 | 2 | import * as assert from "node:assert"; |
3 | | -import { getPsbtFixtures, toPsbtWithPrevOutOnly } from "./psbtFixtures"; |
| 3 | +import { getPsbtFixtures } from "./psbtFixtures"; |
4 | 4 | import { Descriptor, Psbt } from "../js"; |
5 | 5 |
|
6 | 6 | import { getDescriptorForScriptType } from "./descriptorUtil"; |
| 7 | +import { toUtxoPsbt, toWrappedPsbt } from "./psbt.util"; |
7 | 8 |
|
8 | 9 | const rootWalletKeys = new utxolib.bitgo.RootWalletKeys(utxolib.testutil.getKeyTriple("wasm")); |
9 | 10 |
|
10 | | -function toWrappedPsbt(psbt: utxolib.bitgo.UtxoPsbt | Buffer | Uint8Array) { |
11 | | - if (psbt instanceof utxolib.bitgo.UtxoPsbt) { |
12 | | - psbt = psbt.toBuffer(); |
13 | | - } |
14 | | - if (psbt instanceof Buffer || psbt instanceof Uint8Array) { |
15 | | - return Psbt.deserialize(psbt); |
16 | | - } |
17 | | - throw new Error("Invalid input"); |
18 | | -} |
19 | | - |
20 | | -function toUtxoPsbt(psbt: Psbt | Buffer | Uint8Array) { |
21 | | - if (psbt instanceof Psbt) { |
22 | | - psbt = psbt.serialize(); |
23 | | - } |
24 | | - if (psbt instanceof Buffer || psbt instanceof Uint8Array) { |
25 | | - return utxolib.bitgo.UtxoPsbt.fromBuffer(Buffer.from(psbt), { |
26 | | - network: utxolib.networks.bitcoin, |
27 | | - }); |
28 | | - } |
29 | | - throw new Error("Invalid input"); |
30 | | -} |
31 | | - |
32 | 11 | function assertEqualBuffer(a: Buffer | Uint8Array, b: Buffer | Uint8Array, message?: string) { |
33 | 12 | assert.strictEqual(Buffer.from(a).toString("hex"), Buffer.from(b).toString("hex"), message); |
34 | 13 | } |
|
0 commit comments