<p>This draft PR attempts to add support for native Segwit (p2wpkh) BSQ addresses.</p>
<p>The <a href="https://github.com/priiduneemre/btcd-cli4j">btcd-cli4j</a> 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 <code>getblock</code> Json responses returned to the Java client, including the <code>txinwitness</code> field of the raw tx inputs. These are needed to fill in the <code>TxInput.pubKey</code> 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.</p>
<p>A new, home-grown RPC client is provided using the <a href="https://github.com/briandilley/jsonrpc4j">jsonrpc4j</a> library. Additionally, a simple home-grown socket daemon is provided to receive block hashes sent by the <em>blocknotify</em> script run by bitcoind, replacing the btcd-cli4j version.</p>
<ul>
<li>TODO: Improve the RPC client startup logic - should send a ping or <code>getnetworkinfo</code> message to bitcoind & check the version.</li>
<li>TODO: Fix a consensus issue caused by failure of <em>RpcService.java</em> 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 <code>TxInput.pubKey</code> field in the DAO state). I'm not sure yet if there are any other consensus issues.</li>
<li>TODO: Actually implement and enable the native segwit BSQ keychain and make sure there are no issues.</li>
</ul>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/bisq-network/bisq/pull/5000'>https://github.com/bisq-network/bisq/pull/5000</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Bring ScryptType enum up to date with latest bitcoind</li>
  <li>Add replacement bitcoind RPC client using jsonrpc4j</li>
  <li>Add replacement bitcoind block notification daemon</li>
  <li>Factor out executor shutdown logic into new Utilities method</li>
  <li>Factor out failure callback logic into new Utilities method</li>
  <li>Add missing copyright headers to new files</li>
  <li>Improve exception handling in BitcoindDaemon</li>
  <li>Use new Bitcoind(Client|Daemon) & remove btcd-cli4j</li>
  <li>Enable extraction of segwit pubkeys from raw tx inputs</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-0ca41d0b67dfd15fd230dd0ca8518b579e1a80011aa318ead6a6e0c3c0ee6ee1">apitest/src/main/resources/logback.xml</a>
    (1)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7">build.gradle</a>
    (23)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-954a13a40a21444790276f14d9f6d3b436d9a25407c63649f035fcf6368c12cd">common/src/main/java/bisq/common/util/Utilities.java</a>
    (50)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-88765cda3932d8e625f3a79bbf084c0a8822eda7820bc01b74e167db6fa12d92">core/src/main/java/bisq/core/dao/node/explorer/ExportJsonFilesService.java</a>
    (16)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-44be01dcd43553e3211dc61dad6a5fe873f2150bf9a5ff7d23ee5c07a39c52d7">core/src/main/java/bisq/core/dao/node/full/FullNode.java</a>
    (45)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-48690d31860d630d3e63117d8becd281a6857af04f668121c0208360b0130a83">core/src/main/java/bisq/core/dao/node/full/RawTx.java</a>
    (7)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-27dd94f9248721ec2f07102b176255e348eb1790c11bb8790b5d4d6841400688">core/src/main/java/bisq/core/dao/node/full/RpcService.java</a>
    (218)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-022df2c867f65387751d940903b3efcd130c45dac1865a6e6f5e41902c47f99d">core/src/main/java/bisq/core/dao/node/full/rpc/BitcoindClient.java</a>
    (131)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-e410d149c958045bdb55e0aaa7107086e0ed5a2a43835d27a6da945b77270f94">core/src/main/java/bisq/core/dao/node/full/rpc/BitcoindDaemon.java</a>
    (123)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-40ce952aa50324c229da4b2ea4fdd15e6e6bd44c871670bf17a5abb9051fa482">core/src/main/java/bisq/core/dao/node/full/rpc/NotificationHandlerException.java</a>
    (24)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-3503c995c63384955f6b2c2a721ea597fe8c72f47cd22e9b177cd08a507ac6a0">core/src/main/java/bisq/core/dao/node/full/rpc/dto/PubKeyScript.java</a>
    (42)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-2431cba899cf1dcecad1aa70a2fabc2f6436d5aab7528b6d97c3bf0789e75653">core/src/main/java/bisq/core/dao/node/full/rpc/dto/RawBlock.java</a>
    (66)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-173cdb6d5addb264777d0d6efbf53f44c06d010569cbe6929b548174e45deebb">core/src/main/java/bisq/core/dao/node/full/rpc/dto/RawInput.java</a>
    (45)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-0c67361257e8b444a270a6ec01c2f6ea07a793b9f034ab8ea2fc608b950531ce">core/src/main/java/bisq/core/dao/node/full/rpc/dto/RawOutput.java</a>
    (36)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-a4c10e19730423d9413417b04c9602c9fbf8db8776484d0a76bb71cbbbebbc6d">core/src/main/java/bisq/core/dao/node/full/rpc/dto/RawTransaction.java</a>
    (59)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-4d3549d09fc54ea322e93e1c31e3b04c380b3f1bd0ffa58d7d94a242a7715d14">core/src/main/java/bisq/core/dao/node/full/rpc/dto/SignatureScript.java</a>
    (35)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-55660455de9eb149f5e8cad1b3bbc1c82c8a4bf7c9809c0cfcfafbd17f51c875">core/src/main/java/bisq/core/dao/state/model/blockchain/PubKeyScript.java</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-72609a604991e90afff27a52a6ff8c086e7d95f47b505b73824d18a438c3b23e">core/src/main/java/bisq/core/dao/state/model/blockchain/ScriptType.java</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-e29c56d124859f23f8f5816cebd12b8aed52f9627d55994184ac8abb9b369f6f">core/src/main/java/bisq/core/provider/price/PriceRequest.java</a>
    (10)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-32339999a6f473ec032899a6fb6f704da1293469f112e2b4e9c1888813120474">core/src/test/java/bisq/core/dao/node/full/RpcServiceTest.java</a>
    (140)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-1b44e34b39e4e6525a30b733647776520d30b4d5405d7fb800622dbdc238b302">core/src/test/java/bisq/core/dao/node/full/rpc/BitcoindClientTest.java</a>
    (208)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-ce207c1ad0885030b17d1b5f1f422caf7c60a539371dacb9cf87a8c87d539e96">core/src/test/java/bisq/core/dao/node/full/rpc/BitcoindDaemonTest.java</a>
    (191)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-d775bc580b9aabbf60349a0301c8229c406e4af637eda74dcf51936010e3bb2b">core/src/test/resources/bisq/core/dao/node/full/rpc/getblock-result-verbosity-0.txt</a>
    (53)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-9ee8b3e61af83056a9d24e446f0394557863d41c30380746ee394ab08a547dac">core/src/test/resources/bisq/core/dao/node/full/rpc/getblock-result-verbosity-1.json</a>
    (33)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-3b00ed03683192197dcd0c522649bde588e9ffd90376eeed229e842d14be0c4d">core/src/test/resources/bisq/core/dao/node/full/rpc/getblock-result-verbosity-2.json</a>
    (698)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-b5daa16c4105b58bb3d14376cd7cd427241a2e68a81ba36b6daefad87ce97627">daemon/src/main/resources/logback.xml</a>
    (1)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-010fcf0227335959cb52c09b78f23e5d86d26a9d2c7ca37b023645a7fcee6502">desktop/src/main/resources/logback.xml</a>
    (3)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-33fe0e084fc9da780801d3a024857640ac47aee9b96ad6ab7d866786a326ed26">gradle/witness/gradle-witness.gradle</a>
    (3)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-be57cca0655004e62cfee76be83df112cad05225472874bdd5753f443fdf3bb3">inventory/src/main/resources/logback.xml</a>
    (3)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-575d2ba9d06a2a85908f085ed2a9cc9cc0fb2b7def52f639835a6726499941e6">monitor/src/main/java/bisq/monitor/Metric.java</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-7b7ee1f3002b9ee5a4ad720de62712761e395b5dff69e73764e208796b69b462">p2p/src/main/java/bisq/network/http/HttpException.java</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-9c09d928d4d61b36164dcb068421cce6352ebd211eda408e343adc0d6fbb9826">p2p/src/main/java/bisq/network/p2p/network/TorNetworkNode.java</a>
    (14)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-5faf18a24049cc9f98d8756153bbadd7b8c1e8338df63e6df203d8893a428077">p2p/src/main/java/bisq/network/p2p/peers/keepalive/KeepAliveManager.java</a>
    (28)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-51dcd1d852312df65738ff2bd493fdb0f187f50fb7d7324158c8b57fc1de7da7">proto/src/main/proto/pb.proto</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-87928031f9b035984b1710447107aa4feb94de392b7fd49d93e2e3c6d1dfbfc2">seednode/src/main/resources/logback.xml</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5000/files#diff-dff45e3930882eee058dbcce7323c0b4b2ba2a63e0c5bc691f8b7378ef09a989">statsnode/src/main/resources/logback.xml</a>
    (1)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/bisq-network/bisq/pull/5000.patch'>https://github.com/bisq-network/bisq/pull/5000.patch</a></li>
  <li><a href='https://github.com/bisq-network/bisq/pull/5000.diff'>https://github.com/bisq-network/bisq/pull/5000.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/5000">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNRMCH37H5BW4DE7O5TSWPDF5ANCNFSM4VIT74IQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AJFFTNVDUXLBBESS6TMU243SWPDF5A5CNFSM4VIT74I2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4LRLEOTQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/5000",
"url": "https://github.com/bisq-network/bisq/pull/5000",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>