Detect RBF transactions in explorer and API #237
parent
d450f1d315
commit
d01fc3d914
|
@ -191,6 +191,7 @@ type Tx struct {
|
|||
ValueInSat *Amount `json:"valueIn,omitempty"`
|
||||
FeesSat *Amount `json:"fees,omitempty"`
|
||||
Hex string `json:"hex,omitempty"`
|
||||
Rbf bool `json:"rbf,omitempty"`
|
||||
CoinSpecificData interface{} `json:"-"`
|
||||
CoinSpecificJSON json.RawMessage `json:"-"`
|
||||
TokenTransfers []TokenTransfer `json:"tokenTransfers,omitempty"`
|
||||
|
|
|
@ -142,6 +142,7 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height uint32,
|
|||
var valInSat, valOutSat, feesSat big.Int
|
||||
var pValInSat *big.Int
|
||||
vins := make([]Vin, len(bchainTx.Vin))
|
||||
rbf := false
|
||||
for i := range bchainTx.Vin {
|
||||
bchainVin := &bchainTx.Vin[i]
|
||||
vin := &vins[i]
|
||||
|
@ -149,6 +150,10 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height uint32,
|
|||
vin.N = i
|
||||
vin.Vout = bchainVin.Vout
|
||||
vin.Sequence = int64(bchainVin.Sequence)
|
||||
// detect explicit Replace-by-Fee transactions as defined by BIP125
|
||||
if bchainTx.Confirmations == 0 && bchainVin.Sequence < 0xffffffff-1 {
|
||||
rbf = true
|
||||
}
|
||||
vin.Hex = bchainVin.ScriptSig.Hex
|
||||
vin.Coinbase = bchainVin.Coinbase
|
||||
if w.chainType == bchain.ChainBitcoinType {
|
||||
|
@ -317,6 +322,7 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height uint32,
|
|||
ValueOutSat: (*Amount)(&valOutSat),
|
||||
Version: bchainTx.Version,
|
||||
Hex: bchainTx.Hex,
|
||||
Rbf: rbf,
|
||||
Vin: vins,
|
||||
Vout: vouts,
|
||||
CoinSpecificData: bchainTx.CoinSpecificData,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<div class="row line-bot">
|
||||
<div class="col-xs-7 col-md-8 ellipsis">
|
||||
<a href="/tx/{{$tx.Txid}}">{{$tx.Txid}}</a>
|
||||
{{- if $tx.Rbf}}<span title="Replace-by-Fee (RBF) transaction, could be overriden"> ⚠️</span>{{end -}}
|
||||
</div>
|
||||
{{- if $tx.Blocktime}}<div class="col-xs-5 col-md-4 text-muted text-right">{{if $tx.Confirmations}}mined{{else}}first seen{{end}} {{formatUnixTime $tx.Blocktime}}</div>{{end -}}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue