[bisq-network/bisq] [WIP] Implement Segwit for BSQ (#5000)
Steven Barclay
notifications at github.com
Fri Dec 25 00:12:30 CET 2020
<!--
- make yourself familiar with the CONTRIBUTING.md if you have not already (https://github.com/bisq-network/bisq/blob/master/CONTRIBUTING.md)
- make sure you follow our [coding style guidelines][https://github.com/bisq-network/style/issues)
- pick a descriptive title
- provide some meaningful PR description below
- create the PR
- in case you receive a "Change request" and/or a NACK, please react within 30 days. If not, we will close your PR and it can not be up for compensation.
- After addressing the change request, __please re-request a review!__ Otherwise we might miss your PR as we tend to only look at pull requests tagged with a "review required".
-->
This draft PR attempts to add support for native Segwit (p2wpkh) BSQ addresses.
The [btcd-cli4j](https://github.com/priiduneemre/btcd-cli4j) Json-RPC interface for bitcoind (which is used by DAO full nodes) is replaced, as that code appears to be unmaintained for about 5 years and only maintained compatibility up to bitcoind-0.10.3. In particular, it does not support the extra Segwit fields in the `getblock` Json responses returned to the Java client, including the `txinwitness` field of the raw tx inputs. These are needed to fill in the `TxInput.pubKey` fields of the inputs of each BSQ tx that makes up the DAO state, used in turn to validate staked merit (from issuance txs) and messages signed for a proof-of-burn tx. Thus the RPC client needs upgrading for us to support compensation and proof-of-burn txs with native Segwit BSQ inputs.
A new, home-grown RPC client is provided using the [jsonrpc4j](https://github.com/briandilley/jsonrpc4j) library. Additionally, a simple home-grown socket daemon is provided to receive block hashes sent by the _blocknotify_ script run by bitcoind, replacing the btcd-cli4j version.
- TODO: Improve the RPC client startup logic - should send a ping or `getnetworkinfo` message to bitcoind & check the version.
- TODO: Fix a consensus issue caused by failure of _RpcService.java_ to account for at least one spurious fully native Segwit BSQ tx (d1f45e55be6101b1b75e6bf9fc5e5341c6ab420647be7555863bbbddd84e92f3) which appeared in block 660384, dated 2020-12-07 (thus missing a `TxInput.pubKey` field in the DAO state). I'm not sure yet if there are any other consensus issues.
- TODO: Actually implement and enable the native segwit BSQ keychain and make sure there are no issues.
You can view, comment on, or merge this pull request online at:
https://github.com/bisq-network/bisq/pull/5000
-- Commit Summary --
* Bring ScryptType enum up to date with latest bitcoind
* Add replacement bitcoind RPC client using jsonrpc4j
* Add replacement bitcoind block notification daemon
* Factor out executor shutdown logic into new Utilities method
* Factor out failure callback logic into new Utilities method
* Add missing copyright headers to new files
* Improve exception handling in BitcoindDaemon
* Use new Bitcoind(Client|Daemon) & remove btcd-cli4j
* Enable extraction of segwit pubkeys from raw tx inputs
-- File Changes --
M apitest/src/main/resources/logback.xml (1)
M build.gradle (23)
M common/src/main/java/bisq/common/util/Utilities.java (50)
M core/src/main/java/bisq/core/dao/node/explorer/ExportJsonFilesService.java (16)
M core/src/main/java/bisq/core/dao/node/full/FullNode.java (45)
M core/src/main/java/bisq/core/dao/node/full/RawTx.java (7)
M core/src/main/java/bisq/core/dao/node/full/RpcService.java (218)
A core/src/main/java/bisq/core/dao/node/full/rpc/BitcoindClient.java (131)
A core/src/main/java/bisq/core/dao/node/full/rpc/BitcoindDaemon.java (123)
A core/src/main/java/bisq/core/dao/node/full/rpc/NotificationHandlerException.java (24)
A core/src/main/java/bisq/core/dao/node/full/rpc/dto/PubKeyScript.java (42)
A core/src/main/java/bisq/core/dao/node/full/rpc/dto/RawBlock.java (66)
A core/src/main/java/bisq/core/dao/node/full/rpc/dto/RawInput.java (45)
A core/src/main/java/bisq/core/dao/node/full/rpc/dto/RawOutput.java (36)
A core/src/main/java/bisq/core/dao/node/full/rpc/dto/RawTransaction.java (59)
A core/src/main/java/bisq/core/dao/node/full/rpc/dto/SignatureScript.java (35)
M core/src/main/java/bisq/core/dao/state/model/blockchain/PubKeyScript.java (4)
M core/src/main/java/bisq/core/dao/state/model/blockchain/ScriptType.java (6)
M core/src/main/java/bisq/core/provider/price/PriceRequest.java (10)
A core/src/test/java/bisq/core/dao/node/full/RpcServiceTest.java (140)
A core/src/test/java/bisq/core/dao/node/full/rpc/BitcoindClientTest.java (208)
A core/src/test/java/bisq/core/dao/node/full/rpc/BitcoindDaemonTest.java (191)
A core/src/test/resources/bisq/core/dao/node/full/rpc/getblock-result-verbosity-0.txt (53)
A core/src/test/resources/bisq/core/dao/node/full/rpc/getblock-result-verbosity-1.json (33)
A core/src/test/resources/bisq/core/dao/node/full/rpc/getblock-result-verbosity-2.json (698)
M daemon/src/main/resources/logback.xml (1)
M desktop/src/main/resources/logback.xml (3)
M gradle/witness/gradle-witness.gradle (3)
M inventory/src/main/resources/logback.xml (3)
M monitor/src/main/java/bisq/monitor/Metric.java (10)
M p2p/src/main/java/bisq/network/http/HttpException.java (4)
M p2p/src/main/java/bisq/network/p2p/network/TorNetworkNode.java (14)
M p2p/src/main/java/bisq/network/p2p/peers/keepalive/KeepAliveManager.java (28)
M proto/src/main/proto/pb.proto (2)
M seednode/src/main/resources/logback.xml (2)
M statsnode/src/main/resources/logback.xml (1)
-- Patch Links --
https://github.com/bisq-network/bisq/pull/5000.patch
https://github.com/bisq-network/bisq/pull/5000.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/5000
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20201224/f50462e2/attachment.htm>
More information about the bisq-github
mailing list