Skip to content

Commit

Permalink
Improve error message about non-active segwit on simnet
Browse files Browse the repository at this point in the history
I started playing with simnet and was confronted with error message:

```
[ERR] FNDG: Unable to broadcast funding tx for ChannelPoint(<point>:0):
-22: TX rejected: transaction <tx> has witness data, but segwit isn't active yet
```

I wasn't aware of the activation period so I got quite puzzled.
Google helped. But I think the message could mention likely cause.

Newly it optionally prints something like:

```
(The threshold for segwit activation is 300 blocks on simnet, current best height is 113)
```
  • Loading branch information
darwin authored and jcvernaleo committed May 13, 2020
1 parent 8512aff commit b298415
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ func (mp *TxPool) validateReplacement(tx *btcutil.Tx,
func (mp *TxPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit, rejectDupOrphans bool) ([]*chainhash.Hash, *TxDesc, error) {
txHash := tx.Hash()

// If a transaction has iwtness data, and segwit isn't active yet, If
// If a transaction has witness data, and segwit isn't active yet, If
// segwit isn't active yet, then we won't accept it into the mempool as
// it can't be mined yet.
if tx.MsgTx().HasWitness() {
Expand All @@ -937,8 +937,14 @@ func (mp *TxPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit, rejec
}

if !segwitActive {
simnetHint := ""
if mp.cfg.ChainParams.Net == wire.SimNet {
bestHeight := mp.cfg.BestHeight()
simnetHint = fmt.Sprintf(" (The threshold for segwit activation is 300 blocks on simnet, "+
"current best height is %d)", bestHeight)
}
str := fmt.Sprintf("transaction %v has witness data, "+
"but segwit isn't active yet", txHash)
"but segwit isn't active yet%s", txHash, simnetHint)
return nil, nil, txRuleError(wire.RejectNonstandard, str)
}
}
Expand Down

0 comments on commit b298415

Please sign in to comment.