Skip to content

Commit

Permalink
Fix issue with claiming swap signature sometimes failing
Browse files Browse the repository at this point in the history
This was due to the wrong vout index (always 0) being given to the ledger sign function. It manifested when claiming swaps started by the node, as it has a privacy feature where it randomises the change output index.
  • Loading branch information
monokh committed Oct 20, 2019
1 parent a53924f commit 4f946cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/bitcoin-ledger-provider/lib/BitcoinLedgerProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class BitcoinLedgerProvider extends LedgerProvider {
return this._sendTransaction(transactions)
}

async signP2SHTransaction (inputTxHex, tx, address, vout, outputScript, lockTime = 0, segwit = false, index = 0) {
async signP2SHTransaction (inputTxHex, tx, address, vout, outputScript, lockTime = 0, segwit = false) {
const app = await this.getApp()
const walletAddress = await this.getWalletAddress(address)

Expand All @@ -118,7 +118,7 @@ export default class BitcoinLedgerProvider extends LedgerProvider {
const ledgerTx = await app.splitTransaction(tx.toHex(), true)
const ledgerOutputs = (await app.serializeTransactionOutputs(ledgerTx)).toString('hex')
const ledgerSig = await app.signP2SHTransaction(
[[ledgerInputTx, index, outputScript.toString('hex'), 0]],
[[ledgerInputTx, vout.n, outputScript.toString('hex'), 0]],
[walletAddress.derivationPath],
ledgerOutputs.toString('hex'),
lockTime,
Expand Down
2 changes: 1 addition & 1 deletion packages/bitcoin-swap-provider/lib/BitcoinSwapProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default class BitcoinSwapProvider extends Provider {
const txfee = calculateFee(1, 1, 3)

swapVout.txid = initiationTxHash
swapVout.vSat = swapVout.value * 1e8
swapVout.vSat = BigNumber(swapVout.value).times(1e8).toNumber()

if (swapVout.vSat - txfee < 0) {
throw new Error('Transaction amount does not cover fee.')
Expand Down

0 comments on commit 4f946cf

Please sign in to comment.