Skip to content

Commit

Permalink
bond fixes for zec and non-segwit assets
Browse files Browse the repository at this point in the history
  • Loading branch information
chappjc committed May 5, 2023
1 parent 0eeb983 commit 1abd06d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 7 additions & 3 deletions client/asset/btc/btc.go
Expand Up @@ -4928,7 +4928,7 @@ func (btc *intermediaryWallet) EstimateSendTxFee(address string, sendAmount, fee
return 0, false, errors.New("output value is dust")
}

tx := wire.NewMsgTx(wire.TxVersion)
tx := wire.NewMsgTx(btc.txVersion())
tx.AddTxOut(wireOP)
fee, err = btc.txFeeEstimator.estimateSendTxFee(tx, btc.feeRateWithFallback(feeRate), subtract)
if err != nil {
Expand Down Expand Up @@ -5164,7 +5164,7 @@ func (btc *baseWallet) MakeBondTx(ver uint16, amt, feeRate uint64, lockTime time
pkh := btcutil.Hash160(pk)

feeRate = btc.feeRateWithFallback(feeRate)
baseTx := wire.NewMsgTx(wire.TxVersion)
baseTx := wire.NewMsgTx(btc.txVersion())

// TL output.
lockTimeSec := lockTime.Unix()
Expand Down Expand Up @@ -5352,7 +5352,11 @@ func (btc *baseWallet) makeBondRefundTxV0(txid *chainhash.Hash, vout uint32, amt
}
txIn.Witness = dexbtc.RefundBondScriptSegwit(script, sig, pk)
} else {
sig, err := btc.signNonSegwit(msgTx, 0, script, txscript.SigHashAll, priv, []int64{int64(amt)}, [][]byte{script})
prevPkScript, err := btc.scriptHashScript(script) // P2SH: OP_HASH160 <script hash> OP_EQUAL
if err != nil {
return nil, fmt.Errorf("error constructing p2sh script: %w", err)
}
sig, err := btc.signNonSegwit(msgTx, 0, script, txscript.SigHashAll, priv, []int64{int64(amt)}, [][]byte{prevPkScript})
if err != nil {
return nil, err
}
Expand Down
12 changes: 9 additions & 3 deletions dex/testing/dcrdex/harness.sh
Expand Up @@ -274,7 +274,9 @@ if [ $DOGE_ON -eq 0 ]; then
"network": "simnet",
"maxFeeRate": 40000,
"swapConf": 2,
"configPath": "${TEST_ROOT}/doge/alpha/alpha.conf"
"configPath": "${TEST_ROOT}/doge/alpha/alpha.conf",
"bondAmt": 200000000,
"bondConfs": 1
EOF
fi

Expand All @@ -286,7 +288,9 @@ if [ $ZEC_ON -eq 0 ]; then
"network": "simnet",
"maxFeeRate": 200,
"swapConf": 1,
"configPath": "${TEST_ROOT}/zec/alpha/alpha.conf"
"configPath": "${TEST_ROOT}/zec/alpha/alpha.conf",
"bondAmt": 40000000,
"bondConfs": 1
EOF
fi

Expand All @@ -298,7 +302,9 @@ if [ $DGB_ON -eq 0 ]; then
"network": "simnet",
"maxFeeRate": 2000,
"swapConf": 1,
"configPath": "${TEST_ROOT}/dgb/alpha/alpha.conf"
"configPath": "${TEST_ROOT}/dgb/alpha/alpha.conf",
"bondAmt": 800000000,
"bondConfs": 1
EOF
fi

Expand Down

0 comments on commit 1abd06d

Please sign in to comment.