From 6faaef849993c0513e33e7fa9a53350d37ea2501 Mon Sep 17 00:00:00 2001 From: Kodemon Date: Mon, 10 Jul 2023 15:08:34 +0900 Subject: [PATCH] chore(order): fix signable psbt --- src/Methods/Order/CreateSignablePsbt.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Methods/Order/CreateSignablePsbt.ts b/src/Methods/Order/CreateSignablePsbt.ts index ec89256..23fd586 100644 --- a/src/Methods/Order/CreateSignablePsbt.ts +++ b/src/Methods/Order/CreateSignablePsbt.ts @@ -34,8 +34,21 @@ export const createSignablePsbt = method({ } const psbt = new Psbt({ network: btcNetwork }); + const type = utils.bitcoin.getAddressType(maker); - if (tapInternalKey !== undefined) { + if (type === "bech32") { + psbt.addInput({ + hash, + index, + witnessUtxo: { + script: Buffer.from(vout.scriptPubKey.hex, "hex"), + value: 0, + }, + }); + } else if (type === "taproot") { + if (tapInternalKey === undefined) { + throw new BadRequestError("Taproot address requires a pubkey"); + } psbt.addInput({ hash, index,