fix(XLinkSDK): ask change address for brc20/runes peg-in methods

This commit is contained in:
c4605
2025-03-28 13:11:48 +01:00
parent 70386adfa9
commit b63dd0d5b3
4 changed files with 26 additions and 8 deletions

View File

@@ -94,10 +94,13 @@ export interface BridgeFromBRC20Input {
toAddressScriptPubKey?: Uint8Array
inputInscriptionUTXO: UTXOSpendable
swapRoute?: SwapRoute_WithMinimumAmountsToReceive_Public
networkFeeRate: bigint
swapRoute?: SwapRoute_WithMinimumAmountsToReceive_Public
reselectSpendableNetworkFeeUTXOs: BridgeFromBRC20Input_reselectSpendableNetworkFeeUTXOs
networkFeeChangeAddress: string
networkFeeChangeAddressScriptPubKey: Uint8Array
signPsbt: BridgeFromBRC20Input_signPsbtFn
sendTransaction: (tx: {
hex: string
@@ -641,7 +644,7 @@ async function constructBRC20Transaction(
const tx = createTransaction(
txOptions.inputs,
txOptions.recipients.concat({
addressScriptPubKey: info.fromAddressScriptPubKey,
addressScriptPubKey: info.networkFeeChangeAddressScriptPubKey,
satsAmount: txOptions.changeAmount,
}),
txOptions.opReturnScripts ?? [],
@@ -698,8 +701,12 @@ export type PrepareBRC20TransactionInput = KnownRoute_FromBRC20 & {
fromAddress: BridgeFromBRC20Input["fromAddress"]
toAddress: BridgeFromBRC20Input["toAddress"]
inputInscriptionUTXO: BridgeFromBRC20Input["inputInscriptionUTXO"]
networkFeeRate: BridgeFromBRC20Input["networkFeeRate"]
networkFeeChangeAddress: string
networkFeeChangeAddressScriptPubKey: Uint8Array
reselectSpendableNetworkFeeUTXOs: BridgeFromBRC20Input["reselectSpendableNetworkFeeUTXOs"]
pegInAddress: BitcoinAddress
orderData: Uint8Array
bridgeFeeOutput: null | {
@@ -796,7 +803,7 @@ export async function prepareBRC20Transaction(
},
]),
],
changeAddressScriptPubKey: info.fromAddressScriptPubKey,
changeAddressScriptPubKey: info.networkFeeChangeAddressScriptPubKey,
feeRate: info.networkFeeRate,
reselectSpendableUTXOs: reselectSpendableUTXOsFactory(
info.reselectSpendableNetworkFeeUTXOs,

View File

@@ -105,10 +105,13 @@ export interface BridgeFromRunesInput {
amount: SDKNumber
inputRuneUTXOs: RunesUTXOSpendable[]
swapRoute?: SwapRoute_WithMinimumAmountsToReceive_Public
networkFeeRate: bigint
swapRoute?: SwapRoute_WithMinimumAmountsToReceive_Public
networkFeeChangeAddress: string
networkFeeChangeAddressScriptPubKey: Uint8Array
reselectSpendableNetworkFeeUTXOs: BridgeFromRunesInput_reselectSpendableNetworkFeeUTXOs
signPsbt: BridgeFromRunesInput_signPsbtFn
sendTransaction: (tx: {
hex: string
@@ -587,7 +590,7 @@ async function constructRunesTransaction(
const tx = createTransaction(
txOptions.inputs,
txOptions.recipients.concat({
addressScriptPubKey: info.fromAddressScriptPubKey,
addressScriptPubKey: info.networkFeeChangeAddressScriptPubKey,
satsAmount: txOptions.changeAmount,
}),
txOptions.opReturnScripts ?? [],
@@ -645,8 +648,12 @@ export type PrepareRunesTransactionInput = KnownRoute_FromRunes & {
toAddress: BridgeFromRunesInput["toAddress"]
amount: BridgeFromRunesInput["amount"]
inputRuneUTXOs: BridgeFromRunesInput["inputRuneUTXOs"]
networkFeeRate: BridgeFromRunesInput["networkFeeRate"]
networkFeeChangeAddress: string
networkFeeChangeAddressScriptPubKey: Uint8Array
reselectSpendableNetworkFeeUTXOs: BridgeFromRunesInput["reselectSpendableNetworkFeeUTXOs"]
pegInAddress: BitcoinAddress
orderData: Uint8Array
bridgeFeeOutput: null | {
@@ -845,7 +852,7 @@ export async function prepareRunesTransaction(
),
},
],
changeAddressScriptPubKey: info.fromAddressScriptPubKey,
changeAddressScriptPubKey: info.networkFeeChangeAddressScriptPubKey,
feeRate: info.networkFeeRate,
opReturnScripts: [runesOpReturnScript],
reselectSpendableUTXOs: reselectSpendableUTXOsFactory(

View File

@@ -58,9 +58,11 @@ export interface EstimateBridgeTransactionFromBRC20Input {
toAddressScriptPubKey?: Uint8Array
inputInscriptionUTXO: UTXOSpendable
swapRoute?: SwapRoute_WithMinimumAmountsToReceive_Public
networkFeeRate: bigint
networkFeeChangeAddress: string
networkFeeChangeAddressScriptPubKey: Uint8Array
reselectSpendableNetworkFeeUTXOs: BridgeFromBRC20Input_reselectSpendableNetworkFeeUTXOs
}

View File

@@ -59,9 +59,11 @@ export interface EstimateBridgeTransactionFromRunesInput {
amount: SDKNumber
inputRuneUTXOs: RunesUTXOSpendable[]
swapRoute?: SwapRoute_WithMinimumAmountsToReceive_Public
networkFeeRate: bigint
networkFeeChangeAddress: string
networkFeeChangeAddressScriptPubKey: Uint8Array
reselectSpendableNetworkFeeUTXOs: BridgeFromRunesInput_reselectSpendableNetworkFeeUTXOs
}