mirror of
https://github.com/Brotocol-xyz/bro-sdk.git
synced 2026-01-12 14:54:21 +08:00
fix: prevent dust change output
This commit is contained in:
@@ -723,12 +723,17 @@ async function constructBRC20Transaction(
|
||||
}> {
|
||||
const txOptions = await prepareBRC20Transaction(sdkContext, info)
|
||||
|
||||
const recipients =
|
||||
txOptions.changeAmount > 0n
|
||||
? txOptions.recipients.concat({
|
||||
addressScriptPubKey: info.networkFeeChangeAddressScriptPubKey,
|
||||
satsAmount: txOptions.changeAmount,
|
||||
})
|
||||
: txOptions.recipients
|
||||
|
||||
const tx = createTransaction(
|
||||
txOptions.inputs,
|
||||
txOptions.recipients.concat({
|
||||
addressScriptPubKey: info.networkFeeChangeAddressScriptPubKey,
|
||||
satsAmount: txOptions.changeAmount,
|
||||
}),
|
||||
recipients,
|
||||
txOptions.opReturnScripts ?? [],
|
||||
)
|
||||
|
||||
@@ -812,6 +817,7 @@ export type PrepareBRC20TransactionInput = KnownRoute_FromBRC20 & {
|
||||
* * Peg-in order data
|
||||
* * Bridge fee (optional)
|
||||
* * Hard linkage (optional)
|
||||
* * ...extra outputs
|
||||
* * BTC change (optional)
|
||||
*
|
||||
* (with bridge fee example tx) https://mempool.space/testnet/tx/e127a2d3c343675a1cde8ca8d10ae5621b40d309ce44b4f45bedc10499f8d596
|
||||
|
||||
@@ -669,12 +669,17 @@ async function constructRunesTransaction(
|
||||
info,
|
||||
)
|
||||
|
||||
const recipients =
|
||||
txOptions.changeAmount > 0n
|
||||
? txOptions.recipients.concat({
|
||||
addressScriptPubKey: info.networkFeeChangeAddressScriptPubKey,
|
||||
satsAmount: txOptions.changeAmount,
|
||||
})
|
||||
: txOptions.recipients
|
||||
|
||||
const tx = createTransaction(
|
||||
txOptions.inputs,
|
||||
txOptions.recipients.concat({
|
||||
addressScriptPubKey: info.networkFeeChangeAddressScriptPubKey,
|
||||
satsAmount: txOptions.changeAmount,
|
||||
}),
|
||||
recipients,
|
||||
txOptions.opReturnScripts ?? [],
|
||||
)
|
||||
|
||||
@@ -760,6 +765,7 @@ export type PrepareRunesTransactionInput = KnownRoute_FromRunes & {
|
||||
* * Bridge fee (optional)
|
||||
* * Hard linkage (optional)
|
||||
* * Peg-in Rune tokens
|
||||
* * ...extra outputs
|
||||
* * BTC change (optional)
|
||||
* * Runestone
|
||||
*
|
||||
@@ -943,6 +949,10 @@ export async function prepareRunesTransaction(
|
||||
}),
|
||||
),
|
||||
},
|
||||
...info.extraOutputs.map(o => ({
|
||||
addressScriptPubKey: o.address.scriptPubKey,
|
||||
satsAmount: o.satsAmount,
|
||||
})),
|
||||
],
|
||||
changeAddressScriptPubKey: info.networkFeeChangeAddressScriptPubKey,
|
||||
feeRate: info.networkFeeRate,
|
||||
|
||||
Reference in New Issue
Block a user