Skip to content

Commit

Permalink
feat: mm-snap compat and txid return
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Hill <[email protected]>
  • Loading branch information
gregdhill committed Sep 3, 2024
1 parent 8344450 commit 0045b6b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gobob/bob-sdk",
"version": "2.2.1",
"version": "2.2.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion sdk/src/gateway/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ export class GatewayApiClient {
*
* @param uuid The id given by the {@link startOrder} method.
* @param bitcoinTxHex The hex encoded Bitcoin transaction.
* @returns {Promise<string>} The Bitcoin txid.
*/
async finalizeOrder(uuid: string, bitcoinTxHex: string) {
async finalizeOrder(uuid: string, bitcoinTxHex: string): Promise<string> {
const response = await fetch(`${this.baseUrl}/order/${uuid}`, {
method: "PATCH",
headers: {
Expand All @@ -220,6 +221,8 @@ export class GatewayApiClient {
if (!response.ok) {
throw new Error("Failed to update order");
}

return await response.json();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/wallet/utxo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ export function getInputFromUtxoAndTx(
amount: output.amount!,
},
};
const witnessMixin = transaction.hasWitnesses ? witnessUtxo : nonWitnessUtxo;
const witnessMixin = transaction.hasWitnesses ? { ...witnessUtxo, ...nonWitnessUtxo } : nonWitnessUtxo;

// Construct inputs based on the script type
const input = {
txid: utxo.txid,
index: utxo.vout,
...scriptMixin, // Maybe adds the redeemScript and/or witnessScript
...witnessMixin, // Adds the witnessUtxo or nonWitnessUtxo
...witnessMixin, // Adds the witnessUtxo and/or nonWitnessUtxo
};

return input;
Expand Down

0 comments on commit 0045b6b

Please sign in to comment.