Improve error message about non-active segwit on simnet

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)
```
This commit is contained in:
Antonin Hildebrand 2019-03-25 23:24:06 +01:00 committed by John C. Vernaleo
parent 8512affc59
commit b298415583

View file

@ -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() {
@ -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)
}
}