Skip to content

Commit

Permalink
feat: cleanup dfns handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Dec 4, 2024
1 parent fd153ad commit ae4bf61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "dlc-btc-lib",
"version": "2.4.20",
"version": "2.4.21",
"description": "This library provides a comprehensive set of interfaces and functions for minting dlcBTC tokens on supported blockchains.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
15 changes: 5 additions & 10 deletions src/dlc-handlers/dfns-dlc-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { WebAuthnSigner } from '@dfns/sdk-browser';
import { GenerateSignatureBody, ListWalletsResponse } from '@dfns/sdk/generated/wallets/types.js';
import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
import { Transaction, p2tr } from '@scure/btc-signer';
import { P2Ret, P2TROut } from '@scure/btc-signer/payment';
import { P2TROut } from '@scure/btc-signer/payment';
import { Network } from 'bitcoinjs-lib';

import {
Expand Down Expand Up @@ -50,7 +50,7 @@ export class DFNSDLCHandler {
this.bitcoinNetwork = bitcoinNetwork;
}

private setPayment(fundingPayment: P2Ret | P2TROut, multisigPayment: P2TROut): void {
private setPayment(fundingPayment: P2TROut, multisigPayment: P2TROut): void {
this.payment = {
fundingPayment,
multisigPayment,
Expand Down Expand Up @@ -120,21 +120,17 @@ export class DFNSDLCHandler {
throw new Error('Payment Objects have not been set');
}

let address: string;

switch (paymentType) {
case 'funding':
if (!payment.fundingPayment.address) {
throw new Error('Funding Payment Address is undefined');
}
address = payment.fundingPayment.address;
return address;
return payment.fundingPayment.address;
case 'multisig':
if (!payment.multisigPayment.address) {
throw new Error('Taproot Multisig Payment Address is undefined');
}
address = payment.multisigPayment.address;
return address;
return payment.multisigPayment.address;
default:
throw new Error('Invalid Payment Type');
}
Expand All @@ -148,6 +144,7 @@ export class DFNSDLCHandler {
if (!this.taprootDerivedPublicKey) {
throw new Error('Taproot Derived Public Key not set');
}

const fundingPayment = p2tr(
ecdsaPublicKeyToSchnorr(Buffer.from(this.taprootDerivedPublicKey, 'hex')),
undefined,
Expand Down Expand Up @@ -323,8 +320,6 @@ export class DFNSDLCHandler {
}
);

console.log('generateSignatureCompleteResponse', generateSignatureCompleteResponse);

const signedPSBT = generateSignatureCompleteResponse.signedData;

if (!signedPSBT) {
Expand Down

0 comments on commit ae4bf61

Please sign in to comment.