-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client/btc: Use coin specific tx hashes. #2342
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. There are so many gotchas with zcash and it's about to get trickier with #2338
I wonder if we should make zec not a clone wallet any more. This fix looks good though.
I see a few more wrong hashes if you wanna add these: diff --git a/client/asset/btc/btc.go b/client/asset/btc/btc.go
index e36a38649..21988027e 100644
--- a/client/asset/btc/btc.go
+++ b/client/asset/btc/btc.go
@@ -3109,7 +3109,7 @@ func accelerateOrder(btc *baseWallet, swapCoins, accelerationCoins []dex.Bytes,
delete(btc.fundingCoins, newOutPoint(changeTxHash, changeVout))
if newChange == nil {
- return nil, signedTx.TxHash().String(), nil
+ return nil, btc.hashTx(signedTx).String(), nil
}
// Add the new change to the cache if needed. We check if
@@ -3137,7 +3137,7 @@ func accelerateOrder(btc *baseWallet, swapCoins, accelerationCoins []dex.Bytes,
// return nil error since tx is already broadcast, and core needs to update
// the change coin
- return newChange, signedTx.TxHash().String(), nil
+ return newChange, btc.hashTx(signedTx).String(), nil
}
// AccelerationEstimate takes the same parameters as AccelerateOrder, but
@@ -5314,7 +5314,7 @@ func (btc *baseWallet) MakeBondTx(ver uint16, amt, feeRate uint64, lockTime time
return nil, nil, fmt.Errorf("failed to sign bond tx: %w", err)
}
- txid := signedTx.TxHash()
+ txid := btc.hashTx(signedTx)
signedTxBytes, err := serializeMsgTx(signedTx)
if err != nil {
@@ -5326,7 +5326,7 @@ func (btc *baseWallet) MakeBondTx(ver uint16, amt, feeRate uint64, lockTime time
}
// Prep the redeem / refund tx.
- redeemMsgTx, err := btc.makeBondRefundTxV0(&txid, 0, amt, bondScript, bondKey, feeRate)
+ redeemMsgTx, err := btc.makeBondRefundTxV0(txid, 0, amt, bondScript, bondKey, feeRate)
if err != nil {
return nil, nil, fmt.Errorf("unable to create bond redemption tx: %w", err)
}
@@ -5339,7 +5339,7 @@ func (btc *baseWallet) MakeBondTx(ver uint16, amt, feeRate uint64, lockTime time
Version: ver,
AssetID: btc.cloneParams.AssetID,
Amount: amt,
- CoinID: toCoinID(&txid, 0),
+ CoinID: toCoinID(txid, 0),
Data: bondScript,
SignedTx: signedTxBytes,
UnsignedTx: unsignedTxBytes, |
Oh crud, also, |
should work but haven't tried it: diff --git a/client/asset/btc/btc.go b/client/asset/btc/btc.go
index 5ac495bef..b4b689780 100644
--- a/client/asset/btc/btc.go
+++ b/client/asset/btc/btc.go
@@ -5316,11 +5316,11 @@ func (btc *baseWallet) MakeBondTx(ver uint16, amt, feeRate uint64, lockTime time
txid := signedTx.TxHash()
- signedTxBytes, err := serializeMsgTx(signedTx)
+ signedTxBytes, err := btc.serializeTx(signedTx)
if err != nil {
return nil, nil, err
}
- unsignedTxBytes, err := serializeMsgTx(baseTx)
+ unsignedTxBytes, err := btc.serializeTx(baseTx)
if err != nil {
return nil, nil, err
}
@@ -5330,7 +5330,7 @@ func (btc *baseWallet) MakeBondTx(ver uint16, amt, feeRate uint64, lockTime time
if err != nil {
return nil, nil, fmt.Errorf("unable to create bond redemption tx: %w", err)
}
- redeemTx, err := serializeMsgTx(redeemMsgTx)
+ redeemTx, err := btc.serializeTx(redeemMsgTx)
if err != nil {
return nil, nil, fmt.Errorf("failed to serialize bond redemption tx: %w", err)
} |
closes #2327