Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/wasm-miniscript/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ export type DescriptorPkType = "derivable" | "definite" | "string";

export type ScriptContext = "tap" | "segwitv0" | "legacy";

export type SignPsbtInputResult = { Ecdsa: string[] } | { Schnorr: string[] };

export type SignPsbtResult = {
[inputIndex: number]: [pubkey: string][];
[inputIndex: number]: SignPsbtInputResult;
};

declare module "./wasm/wasm_miniscript" {
Expand Down
13 changes: 5 additions & 8 deletions packages/wasm-miniscript/test/psbtFromDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getKey } from "@bitgo/utxo-lib/dist/src/testutil";

import { DescriptorNode, formatNode } from "../js/ast";
import { mockPsbtDefault } from "./psbtFromDescriptor.util";
import { Descriptor } from "../js";
import { Descriptor, SignPsbtInputResult, SignPsbtResult } from "../js";
import { toWrappedPsbt } from "./psbt.util";

function toKeyWithPath(k: BIP32Interface, path = "*"): string {
Expand Down Expand Up @@ -59,12 +59,9 @@ function describeSignDescriptor(
),
});

function getSigResult(keys: (BIP32Interface | ECPairInterface)[]) {
return {
[isTaproot ? "Schnorr" : "Ecdsa"]: keys.map((key) =>
key.publicKey.subarray(isTaproot ? 1 : 0).toString("hex"),
),
};
function getSigResult(keys: (BIP32Interface | ECPairInterface)[]): SignPsbtInputResult {
const pks = keys.map((key) => key.publicKey.subarray(isTaproot ? 1 : 0).toString("hex"));
return isTaproot ? { Schnorr: pks } : { Ecdsa: pks };
}

signBip32.forEach((signSeq, i) => {
Expand Down Expand Up @@ -100,7 +97,7 @@ function describeSignDescriptor(
assert.deepStrictEqual(wrappedPsbt.signWithPrv(key.privateKey), {
0: getSigResult([key]),
1: getSigResult([key]),
});
} satisfies SignPsbtResult);
});
wrappedPsbt.finalize();
});
Expand Down
Loading