Skip to content

Commit

Permalink
fix!: rename to maxSignerFee for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Dec 3, 2024
1 parent 96261b3 commit 97773a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions packages/sbtc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ npm install sbtc
- **Processing by Signers:** (_no action required_)
- The signers retrieve and verify the deposit transaction from the Bitcoin blockchain.
- Once verified, the signers mint the equivalent amount of sBTC on the Stacks network.
- **Receive sBTC:** (_no action required_)
- **Receive sBTC (Stacks):** (_no action required_)
- The minted sBTC is sent to the depositor's designated Stacks address, completing the deposit process.
- sBTC is SIP-010 compatible and will show up in wallets and explorers.
- sBTC is SIP-010 compatible and will show up in Stacks wallets and explorers.

#### Withdraw Flow

Expand Down Expand Up @@ -159,7 +159,7 @@ const sbtcBalance = await client.fetchSbtcBalance(STX_ADDRESS); // fetch the sBT
| | | | |
| `paymentPublicKey` | Optional payment public key (currently only used for default utxoToSpendable.sh implementation) | `string` hex ||
| `utxoToSpendable` | Optional function to convert p2wpk and p2sh utxos to spendable inputs | `Function` | Best effort default implementation to make utxos spendable |
| `maxFee` | Optional maximum fee to pay for the deposit transaction | `number` | `80_000` |
| `maxSignerFee` | Optional maximum fee to pay for the deposit transaction | `number` | `80_000` |
| `reclaimLockTime` | Optional reclaim lock time | `number` | `6_000` |
| `network` | Optional Bitcoin network | `BitcoinNetwork` | `REGTEST` |

Expand Down Expand Up @@ -189,7 +189,7 @@ const deposit = buildSbtcDepositTx({
amountSats,
stacksAddress,
signersPublicKey,
maxFee,
maxSignerFee,
reclaimLockTime,
});

Expand Down
20 changes: 10 additions & 10 deletions packages/sbtc/src/transactions/deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ import {
const concat = P.utils.concatBytes;

export function buildSbtcDepositScript(opts: {
maxFee: number;
maxSignerFee: number;
stacksAddress: string;
signersPublicKey: string;
}) {
const maxFeeBytes = P.U64BE.encode(BigInt(opts.maxFee));
const maxSignerFeeBytes = P.U64BE.encode(BigInt(opts.maxSignerFee));
const recipientBytes = stacksAddressBytes(opts.stacksAddress);
const signersPublicKeyBytes = hexToBytes(opts.signersPublicKey);

return btc.Script.encode([
concat(maxFeeBytes, recipientBytes),
concat(maxSignerFeeBytes, recipientBytes),
'DROP',
signersPublicKeyBytes,
'CHECKSIG',
Expand All @@ -42,7 +42,7 @@ export function buildSbtcDepositTr(opts: {
network: BitcoinNetwork;
stacksAddress: string;
signersPublicKey: string;
maxFee: number;
maxSignerFee: number;
lockTime: number;
}) {
const deposit = buildSbtcDepositScript(opts);
Expand Down Expand Up @@ -71,15 +71,15 @@ export function buildSbtcDepositTx({
amountSats,
stacksAddress,
signersPublicKey,
maxFee,
maxSignerFee,
reclaimLockTime,
}: {
network: BitcoinNetwork;
amountSats: number;
stacksAddress: string;
/** Aggregated (schnorr) public key of all signers */
signersPublicKey: string;
maxFee: number;
maxSignerFee: number;
reclaimLockTime: number;
}) {
// todo: check opts, e.g. pub key length to be schnorr
Expand All @@ -88,7 +88,7 @@ export function buildSbtcDepositTx({
network,
stacksAddress,
signersPublicKey,
maxFee,
maxSignerFee,
lockTime: reclaimLockTime,
});
if (!tr.trOut.address) throw new Error('Failed to create build taproot output');
Expand All @@ -109,7 +109,7 @@ export async function sbtcDepositHelper({
utxos,
utxoToSpendable = DEFAULT_UTXO_TO_SPENDABLE,
paymentPublicKey,
maxFee = 80_000,
maxSignerFee = 80_000,
reclaimLockTime = 6_000,
}: {
/** Bitcoin network, defaults to REGTEST */
Expand Down Expand Up @@ -145,7 +145,7 @@ export async function sbtcDepositHelper({
utxoToSpendable?: Partial<SpendableByScriptTypes>;

/** Optional maximum fee to pay for the deposit transaction, defaults to 80_000 */
maxFee?: number;
maxSignerFee?: number;
/** Optional reclaim lock time, defaults to 6_000 */
reclaimLockTime?: number;

Expand All @@ -161,7 +161,7 @@ export async function sbtcDepositHelper({
amountSats,
stacksAddress,
signersPublicKey,
maxFee,
maxSignerFee,
reclaimLockTime,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/sbtc/tests/deposit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ test('btc tx, deposit to sbtc, tx compare to cli', async () => {
stacksAddress: 'STGSJA8EMYDBAJDX6Z4ED8CWW071B6NB97SRAM1E',
amountSats: 20_042,

maxFee: 20_000,
maxSignerFee: 20_000,
reclaimLockTime: 50,

signersPublicKey: '14c515722f2b61f9bc8bfbcd48422988533007602c74f3145616817f27302237',
Expand Down

0 comments on commit 97773a3

Please sign in to comment.