Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions client/asset/btc/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -4421,6 +4422,11 @@ func (btc *baseWallet) RegFeeConfirmations(_ context.Context, id dex.Bytes) (con
return
}

// BondConfirmations gets the numer of confirmations since the creation of a bond.
func (btc *baseWallet) BondConfirmations(_ context.Context, id dex.Bytes) (confs uint32, err error) {
return btc.RegFeeConfirmations(context.Background(), id)
}

func (btc *baseWallet) checkPeers() {
numPeers, err := btc.node.peerCount()
if err != nil {
Expand Down Expand Up @@ -4972,8 +4978,11 @@ func (btc *baseWallet) MakeBondTx(ver uint16, amt, feeRate uint64, lockTime time

bondInfo := &asset.BondTxInfo{
AccountID: acctID,
LockTime: uint64(lockTimeSec),
BondID: pkh,
Bond: &asset.BondInfo{
ID: hex.EncodeToString(pkh),
Amount: amt,
LockTime: uint64(lockTimeSec),
},
}

btc.addTxToHistory(asset.CreateBond, txid, amt, fee, bondInfo, nil, false)
Expand Down Expand Up @@ -5091,9 +5100,13 @@ func (btc *baseWallet) RefundBond(ctx context.Context, ver uint16, coinID, scrip
fees = amt - uint64(msgTx.TxOut[0].Value)
}
bondInfo := &asset.BondTxInfo{
LockTime: uint64(lockTime),
BondID: pkhPush,
Bond: &asset.BondInfo{
ID: hex.EncodeToString(pkhPush),
Amount: amt,
LockTime: uint64(lockTime),
},
}

btc.addTxToHistory(asset.RedeemBond, txID, amt, fees, bondInfo, nil, true)
return NewOutput(txHash, 0, uint64(msgTx.TxOut[0].Value)), nil
}
Expand Down
26 changes: 18 additions & 8 deletions client/asset/dcr/dcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -4237,9 +4237,11 @@ func (dcr *ExchangeWallet) MakeBondTx(ver uint16, amt, feeRate uint64, lockTime
success = true

bondInfo := &asset.BondTxInfo{
AccountID: acctID,
LockTime: uint64(lockTimeSec),
BondID: pkh,
Bond: &asset.BondInfo{
ID: hex.EncodeToString(pkh),
Amount: amt,
LockTime: uint64(lockTimeSec),
},
}
dcr.addTxToHistory(asset.CreateBond, txHash, amt, fee, bondInfo, nil, false)
txIDToRemoveFromHistory = txHash
Expand Down Expand Up @@ -4332,13 +4334,16 @@ func (dcr *ExchangeWallet) RefundBond(ctx context.Context, ver uint16, coinID, s
return nil, translateRPCCancelErr(err)
}

refundAmt := msgTx.TxOut[0].Value
fees := amt - uint64(msgTx.TxOut[0].Value)
bondInfo := &asset.BondTxInfo{
LockTime: uint64(lockTime),
BondID: pkhPush,
Bond: &asset.BondInfo{
ID: hex.EncodeToString(pkhPush),
Amount: amt,
LockTime: uint64(lockTime),
},
}
dcr.addTxToHistory(asset.RedeemBond, txHash, amt, amt-uint64(refundAmt), bondInfo, nil, true)
return newOutput(redeemHash, 0, uint64(refundAmt), wire.TxTreeRegular), nil
dcr.addTxToHistory(asset.RedeemBond, txHash, amt, fees, bondInfo, nil, true)
return newOutput(redeemHash, 0, uint64(msgTx.TxOut[0].Value), wire.TxTreeRegular), nil

/* If we need to find the actual unspent bond transaction for any of:
(1) the output amount, (2) the commitment output data, or (3) to ensure
Expand Down Expand Up @@ -4521,6 +4526,11 @@ func (dcr *ExchangeWallet) TransactionConfirmations(ctx context.Context, txID st
return uint32(tx.Confirmations), nil
}

// BondConfirmations gets the numer of confirmations since the creation of a bond.
func (dcr *ExchangeWallet) BondConfirmations(ctx context.Context, coinID dex.Bytes) (confs uint32, err error) {
return dcr.RegFeeConfirmations(ctx, coinID)
}

// RegFeeConfirmations gets the number of confirmations for the specified
// output.
func (dcr *ExchangeWallet) RegFeeConfirmations(ctx context.Context, coinID dex.Bytes) (confs uint32, err error) {
Expand Down
Loading