Skip to content

Commit

Permalink
feat: replace fee recipient argument source (#57)
Browse files Browse the repository at this point in the history
* feat: add fee recipient as argument to psbt functions
  • Loading branch information
Polybius93 authored Feb 5, 2025
1 parent 7e792cc commit ed4fba1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/dlc-handlers/abstract-dlc-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export abstract class AbstractDLCHandler {
vault: RawVault,
depositAmount: bigint,
attestorGroupPublicKey: string,
feeRecipient: string,
feeRateMultiplier?: number,
customFeeRate?: bigint
): Promise<Transaction> {
Expand All @@ -169,7 +170,7 @@ export abstract class AbstractDLCHandler {
multisigPayment,
fundingPayment,
feeRate,
vault.btcFeeRecipient,
feeRecipient,
vault.btcMintFeeBasisPoints.toBigInt()
);
}
Expand All @@ -179,6 +180,7 @@ export abstract class AbstractDLCHandler {
withdrawAmount: bigint,
attestorGroupPublicKey: string,
fundingTransactionID: string,
feeRecipient: string,
feeRateMultiplier?: number,
customFeeRate?: bigint
): Promise<Transaction> {
Expand All @@ -197,7 +199,7 @@ export abstract class AbstractDLCHandler {
multisigPayment,
fundingPayment,
feeRate,
vault.btcFeeRecipient,
feeRecipient,
vault.btcRedeemFeeBasisPoints.toBigInt()
);
}
Expand All @@ -207,6 +209,7 @@ export abstract class AbstractDLCHandler {
depositAmount: bigint,
attestorGroupPublicKey: string,
fundingTransactionID: string,
feeRecipient: string,
feeRateMultiplier?: number,
customFeeRate?: bigint
): Promise<Transaction> {
Expand All @@ -225,7 +228,7 @@ export abstract class AbstractDLCHandler {
multisigPayment,
fundingPayment,
feeRate,
vault.btcFeeRecipient,
feeRecipient,
vault.btcMintFeeBasisPoints.toBigInt()
);
}
Expand Down
9 changes: 6 additions & 3 deletions src/dlc-handlers/ledger-dlc-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export class LedgerDLCHandler extends AbstractDLCHandler {
vault: RawVault,
depositAmount: bigint,
attestorGroupPublicKey: string,
feeRecipient: string,
feeRateMultiplier?: number,
customFeeRate?: bigint
): Promise<Transaction> {
Expand All @@ -260,7 +261,7 @@ export class LedgerDLCHandler extends AbstractDLCHandler {
multisigPayment,
fundingPayment,
feeRate,
vault.btcFeeRecipient,
feeRecipient,
vault.btcMintFeeBasisPoints.toBigInt()
);

Expand Down Expand Up @@ -315,6 +316,7 @@ export class LedgerDLCHandler extends AbstractDLCHandler {
withdrawAmount: bigint,
attestorGroupPublicKey: string,
fundingTransactionID: string,
feeRecipient: string,
feeRateMultiplier?: number,
customFeeRate?: bigint
): Promise<Transaction> {
Expand All @@ -334,7 +336,7 @@ export class LedgerDLCHandler extends AbstractDLCHandler {
multisigPayment,
fundingPayment,
feeRate,
vault.btcFeeRecipient,
feeRecipient,
vault.btcRedeemFeeBasisPoints.toBigInt()
);

Expand Down Expand Up @@ -377,6 +379,7 @@ export class LedgerDLCHandler extends AbstractDLCHandler {
depositAmount: bigint,
attestorGroupPublicKey: string,
fundingTransactionID: string,
feeRecipient: string,
feeRateMultiplier?: number,
customFeeRate?: bigint
): Promise<Transaction> {
Expand All @@ -393,7 +396,7 @@ export class LedgerDLCHandler extends AbstractDLCHandler {
multisigPayment,
fundingPayment,
feeRate,
vault.btcFeeRecipient,
feeRecipient,
vault.btcMintFeeBasisPoints.toBigInt()
);

Expand Down
10 changes: 10 additions & 0 deletions src/functions/ethereum/ethereum-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@ export async function getRawVault(
}
}

export async function getFeeRecipient(dlcManagerContract: Contract): Promise<string> {
try {
const feeRecipient: string = await dlcManagerContract.btcFeeRecipient();
if (!feeRecipient) throw new EthereumError('Fee Recipient not found');
return feeRecipient;
} catch (error) {
throw new EthereumError(`Could not fetch Fee Recipient: ${error}`);
}
}

export async function setupVault(dlcManagerContract: Contract): Promise<any | undefined> {
try {
await dlcManagerContract.callStatic.setupVault();
Expand Down

0 comments on commit ed4fba1

Please sign in to comment.