Use static fields for opReturnData instead of hardcoded mainnet hashes

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2022-12-15 13:05:56 -05:00
parent 3ac6921d7e
commit 57147a672a
No known key found for this signature in database
GPG Key ID: 02AA2BAE387C8307
2 changed files with 7 additions and 5 deletions

View File

@ -45,6 +45,9 @@ import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import static bisq.core.dao.burningman.BurningManPresentationService.OP_RETURN_DATA_LEGACY_BM_DPT;
import static bisq.core.dao.burningman.BurningManPresentationService.OP_RETURN_DATA_LEGACY_BM_FEES;
/**
* Burn target related API. Not touching trade protocol aspects and parameters can be changed here without risking to
* break trade protocol validations.
@ -225,8 +228,7 @@ class BurnTargetService {
.filter(tx -> tx.getBlockHeight() <= chainHeight)
.filter(tx -> {
String hash = Hex.encode(tx.getLastTxOutput().getOpReturnData());
return "1701e47e5d8030f444c182b5e243871ebbaeadb5e82f".equals(hash) ||
"1701293c488822f98e70e047012f46f5f1647f37deb7".equals(hash);
return OP_RETURN_DATA_LEGACY_BM_DPT.contains(hash);
})
.mapToLong(Tx::getBurntBsq)
.sum();
@ -237,7 +239,7 @@ class BurnTargetService {
return proofOfBurnTxs.stream()
.filter(tx -> tx.getBlockHeight() > fromBlock)
.filter(tx -> tx.getBlockHeight() <= chainHeight)
.filter(tx -> "1701721206fe6b40777763de1c741f4fd2706d94775d".equals(Hex.encode(tx.getLastTxOutput().getOpReturnData())))
.filter(tx -> OP_RETURN_DATA_LEGACY_BM_FEES.contains(Hex.encode(tx.getLastTxOutput().getOpReturnData())))
.mapToLong(Tx::getBurntBsq)
.sum();
}

View File

@ -69,14 +69,14 @@ public class BurningManPresentationService implements DaoStateListener {
// Those are the opReturn data used by legacy BM for burning BTC received from DPT.
// For regtest testing burn bsq and use the pre-image `dpt` which has the hash 14af04ea7e34bd7378b034ddf90da53b7c27a277.
// The opReturn data gets additionally prefixed with 1701
private static final Set<String> OP_RETURN_DATA_LEGACY_BM_DPT = Config.baseCurrencyNetwork().isRegtest() ?
static final Set<String> OP_RETURN_DATA_LEGACY_BM_DPT = Config.baseCurrencyNetwork().isRegtest() ?
Set.of("170114af04ea7e34bd7378b034ddf90da53b7c27a277") :
Set.of("1701e47e5d8030f444c182b5e243871ebbaeadb5e82f",
"1701293c488822f98e70e047012f46f5f1647f37deb7");
// The opReturn data used by legacy BM for burning BTC received from BTC trade fees.
// For regtest testing burn bsq and use the pre-image `fee` which has the hash b3253b7b92bb7f0916b05f10d4fa92be8e48f5e6.
// The opReturn data gets additionally prefixed with 1701
private static final Set<String> OP_RETURN_DATA_LEGACY_BM_FEES = Config.baseCurrencyNetwork().isRegtest() ?
static final Set<String> OP_RETURN_DATA_LEGACY_BM_FEES = Config.baseCurrencyNetwork().isRegtest() ?
Set.of("1701b3253b7b92bb7f0916b05f10d4fa92be8e48f5e6") :
Set.of("1701721206fe6b40777763de1c741f4fd2706d94775d");