Skip to content

Commit

Permalink
Function rename and description added
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Sep 29, 2023
1 parent c2cb19f commit 3baf536
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
20 changes: 17 additions & 3 deletions typescript/src/deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export async function submitDepositTransaction(
const bitcoinNetwork = await bitcoinClient.getNetwork()

const { transactionHash, depositUtxo, rawTransaction } =
await assembleDepositTransactionBitcoinJsLib(
await assembleDepositTransaction(
bitcoinNetwork,
deposit,
depositorPrivateKey,
Expand All @@ -179,8 +179,22 @@ export async function submitDepositTransaction(
}
}

// TODO: Description and name change.
export async function assembleDepositTransactionBitcoinJsLib(
/**
* Assembles a Bitcoin P2(W)SH deposit transaction.
* @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet).
* @param deposit - Details of the deposit.
* @param depositorPrivateKey - Bitcoin private key of the depositor.
* @param witness - If true, a witness (P2WSH) transaction will be created.
* Otherwise, a legacy P2SH transaction will be made.
* @param utxos - UTXOs that should be used as transaction inputs.
* @param fee - Transaction fee to be subtracted from the sum of the UTXOs'
* values.
* @returns The outcome consisting of:
* - the deposit transaction hash,
* - the deposit UTXO produced by this transaction.
* - the deposit transaction in the raw format
*/
export async function assembleDepositTransaction(
bitcoinNetwork: BitcoinNetwork,
deposit: Deposit,
depositorPrivateKey: string,
Expand Down
10 changes: 5 additions & 5 deletions typescript/test/deposit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { MockBitcoinClient } from "./utils/mock-bitcoin-client"
import bcoin from "bcoin"
import {
assembleDepositScript,
assembleDepositTransactionBitcoinJsLib,
assembleDepositTransaction,
calculateDepositAddress,
calculateDepositRefundLocktime,
calculateDepositScriptHash,
Expand Down Expand Up @@ -327,7 +327,7 @@ describe("Deposit", () => {
transactionHash,
depositUtxo,
rawTransaction: transaction,
} = await assembleDepositTransactionBitcoinJsLib(
} = await assembleDepositTransaction(
BitcoinNetwork.Testnet,
deposit,
testnetPrivateKey,
Expand Down Expand Up @@ -427,7 +427,7 @@ describe("Deposit", () => {
transactionHash,
depositUtxo,
rawTransaction: transaction,
} = await assembleDepositTransactionBitcoinJsLib(
} = await assembleDepositTransaction(
BitcoinNetwork.Testnet,
deposit,
testnetPrivateKey,
Expand Down Expand Up @@ -704,7 +704,7 @@ describe("Deposit", () => {
beforeEach(async () => {
// Create a deposit transaction.
const fee = BigNumber.from(1520)
const result = await assembleDepositTransactionBitcoinJsLib(
const result = await assembleDepositTransaction(
BitcoinNetwork.Testnet,
deposit,
testnetPrivateKey,
Expand Down Expand Up @@ -749,7 +749,7 @@ describe("Deposit", () => {
beforeEach(async () => {
// Create a deposit transaction.
const fee = BigNumber.from(1520)
;({ depositUtxo } = await assembleDepositTransactionBitcoinJsLib(
;({ depositUtxo } = await assembleDepositTransaction(
BitcoinNetwork.Testnet,
deposit,
testnetPrivateKey,
Expand Down

0 comments on commit 3baf536

Please sign in to comment.