Skip to content

Commit

Permalink
Using updated utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-then committed Sep 27, 2024
1 parent fa106b2 commit 4a24889
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/tests/2wp.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ const execute = (description, getRskHost) => {
const sender2PeginValueInSatoshis = minimumPeginValueInSatoshis;
const peginValueInSatoshis = sender1PeginValueInSatoshis + sender2PeginValueInSatoshis;

const sender1UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo1.btcSenderAddressInfo.address, satoshisToBtc(sender1PeginValueInSatoshis));
const sender2UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo2.btcSenderAddressInfo.address, satoshisToBtc(sender2PeginValueInSatoshis));
const sender1UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo1.btcSenderAddressInfo.address, Number(satoshisToBtc(sender1PeginValueInSatoshis)));
const sender2UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo2.btcSenderAddressInfo.address, Number(satoshisToBtc(sender2PeginValueInSatoshis)));

const sender1ChangeInSatoshis = btcToSatoshis(sender1UtxosInfo.change);
const sender2ChangeInSatoshis = btcToSatoshis(sender2UtxosInfo.change);
const sender1ChangeInSatoshis = Number(btcToSatoshis(sender1UtxosInfo.change));
const sender2ChangeInSatoshis = Number(btcToSatoshis(sender2UtxosInfo.change));

const tx = new bitcoinJsLib.Transaction();

Expand Down Expand Up @@ -189,25 +189,25 @@ const execute = (description, getRskHost) => {
const sender2PeginValueInSatoshis = minimumPeginValueInSatoshis;
const peginValueInSatoshis = sender1PeginValueInSatoshis + sender2PeginValueInSatoshis;

const sender1UtxosInfo = await getAddressUtxosInfo(btcTxHelper, senderRecipientInfo1.btcSenderAddressInfo.address, satoshisToBtc(sender1PeginValueInSatoshis));
const sender2UtxosInfo = await getAddressUtxosInfo(btcTxHelper, senderRecipientInfo2.btcSenderAddressInfo.address, satoshisToBtc(sender2PeginValueInSatoshis));
const sender1UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo1.btcSenderAddressInfo.address, Number(satoshisToBtc(sender1PeginValueInSatoshis)));
const sender2UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo2.btcSenderAddressInfo.address, Number(satoshisToBtc(sender2PeginValueInSatoshis)));

const sender1ChangeInSatoshis = btcToSatoshis(sender1UtxosInfo.change);
const sender2ChangeInSatoshis = btcToSatoshis(sender2UtxosInfo.change);
const sender1ChangeInSatoshis = Number(btcToSatoshis(sender1UtxosInfo.change));
const sender2ChangeInSatoshis = Number(btcToSatoshis(sender2UtxosInfo.change));

const tx = new bitcoinJsLib.Transaction();

// Adding inputs
addInputs(tx, sender1UtxosInfo);
addInputs(tx, sender2UtxosInfo);
addInputs(tx, sender1UtxosInfo.utxos);
addInputs(tx, sender2UtxosInfo.utxos);

// Adding 2 outputs to the federation
addOutputToFed(tx, sender1PeginValueInSatoshis);
addOutputToFed(tx, sender2PeginValueInSatoshis);
addOutput(tx, federationAddress, sender1PeginValueInSatoshis);
addOutput(tx, federationAddress, sender2PeginValueInSatoshis);

// Adding change outputs
addChangeOutput(tx, senderRecipientInfo1.btcSenderAddressInfo.address, sender1ChangeInSatoshis);
addChangeOutput(tx, senderRecipientInfo2.btcSenderAddressInfo.address, sender2ChangeInSatoshis);
addOutput(tx, senderRecipientInfo1.btcSenderAddressInfo.address, sender1ChangeInSatoshis - btcFeeInSatoshis);
addOutput(tx, senderRecipientInfo2.btcSenderAddressInfo.address, sender2ChangeInSatoshis - btcFeeInSatoshis);

const sendersPrivateKeys = [senderRecipientInfo1.btcSenderAddressInfo.privateKey, senderRecipientInfo2.btcSenderAddressInfo.privateKey];

Expand Down

0 comments on commit 4a24889

Please sign in to comment.