Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Dec 18, 2024
2 parents 242ee44 + c46bd41 commit 05e016e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
24 changes: 14 additions & 10 deletions packages/chain-adapters/src/utxo/UtxoBaseAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,25 @@ export abstract class UtxoBaseAdapter<T extends UtxoChainId> implements IChainAd

await Promise.all(uniqueAddresses.map(assertAddressNotSanctioned))

const bip44Params = this.getBip44Params({
accountNumber,
accountType,
isChange: true,
addressIndex: account.chainSpecific.nextChangeAddressIndex,
})

const signTxInputs: BTCSignTxInput[] = []
for (const input of inputs) {
if (!input.path) throw new Error('invalid input')

const data = await this.providers.http.getTransaction({ txid: input.txid })

signTxInputs.push({
addressNList: bip32ToAddressNList(input.path),
// UTXO inputs are not guaranteed to have paths.
// They will in the case of an /api/v1/account/<xpub>/utxos account
// However, if we got utxos from an /api/v1/account/<address>/utxos account (i.e UTXOs for a single address), these will *not* contain a path, which is fine,
// as the path will be the same for *all* UTXOs i.e can be derived from BIP44Params (we're dealing with a single address)
addressNList: input.path
? bip32ToAddressNList(input.path)
: toAddressNList({ ...bip44Params }),
scriptType: accountTypeToScriptType[accountType],
amount: String(input.value),
vout: input.vout,
Expand All @@ -347,13 +358,6 @@ export abstract class UtxoBaseAdapter<T extends UtxoChainId> implements IChainAd
})
}

const bip44Params = this.getBip44Params({
accountNumber,
accountType,
isChange: true,
addressIndex: account.chainSpecific.nextChangeAddressIndex,
})

const addressNList = toAddressNList(bip44Params)

const signTxOutputs = outputs.map<BTCSignTxOutput>(output => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export const getTradeQuote = async (
if (!swapResponse.id) throw Error('Missing Swap Id')
if (!swapResponse.address) throw Error('Missing Deposit Channel')

const depositAddress = swapResponse.address

const getFeeData = async () => {
const { chainNamespace } = fromAssetId(sellAsset.assetId)

Expand All @@ -130,7 +132,7 @@ export const getTradeQuote = async (
case CHAIN_NAMESPACE.Solana: {
const sellAdapter = deps.assertGetSolanaChainAdapter(sellAsset.chainId)
const getFeeDataInput: GetFeeDataInput<KnownChainIds.SolanaMainnet> = {
to: input.receiveAddress,
to: depositAddress,
value: sellAmount,
chainSpecific: {
from: input.sendAddress!,
Expand All @@ -155,7 +157,7 @@ export const getTradeQuote = async (
if (!step.chainflipSpecific)
step.chainflipSpecific = {
chainflipSwapId: swapResponse.id,
chainflipDepositAddress: swapResponse.address,
chainflipDepositAddress: depositAddress,
}

step.chainflipSpecific.chainflipSwapId = swapResponse.id
Expand Down

0 comments on commit 05e016e

Please sign in to comment.