<p>Problem:  Using the API's CLI to edit offers causes add/remove messages to be received on peers in the same envelope batch, then passed to the UI in random order.  When <code>OfferBook</code> receives a remove(offer) event after an add(offer) event, the edited offer will be removed immediately after being added to the UI's <code>OfferBook</code> list.</p>
<p>Fix:  This change uses storage entry sequence number and storage entry payload hash comparisons to avoid the problem.</p>
<ul>
<li>
<p><code>OfferBookListItem</code> Added new constructor taking <code>P2PDataStorage.ByteArray hashOfPayload</code>,<br>
and <code>int sequenceNumber</code> params.  Defined a <code>toString</code> method.</p>
</li>
<li>
<p><code>OfferBook</code> Added new checks on <code>OfferBookListItem</code>'s <code>hashOfPayload</code> and <code>sequenceNumber</code> while<br>
determining if offer candidates should be added or removed from the UI's OfferBook List.<br>
See OfferBook contructor's implementation of OfferBookChangedListener#onAdded and<br>
OfferBookChangedListener#onRemoved.  Added many (maybe too many) comments explaining the add/remove rules,<br>
and plenty of debug statements (maybe too many) to help trace the add/remove event process.</p>
</li>
<li>
<p><code>OfferBookService#OfferBookChangedListener</code> Added new <code>P2PDataStorage.ByteArray</code> hashOfPayload,<br>
and <code>int sequenceNumber</code> params to listener's <code>onAdded</code> and <code>onRemoved</code> method signatures.<br>
Added these two new parameter values to listener.onAdded and listener.onRemoved calls.</p>
</li>
<li>
<p><code>TakeOfferDataModel</code> Replaced unused <code>tradeManager</code> param in <code>offerBook.removeOffer</code><br>
with <code>P2PDataStorage.ByteArray hashOfPayload</code> (null), and <code>int sequenceNumber</code> (-1) params.<br>
<code>OfferBook</code> will remove the candidate offer as before.</p>
</li>
<li>
<p>MarketAlerts<code>Adjusted</code>onAdded<code>&</code>onRemoved` listener method signatures.</p>
</li>
</ul>
<p>This PR is based on <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="925426574" data-permission-text="Title is private" data-url="https://github.com/bisq-network/bisq/issues/5577" data-hovercard-type="pull_request" data-hovercard-url="/bisq-network/bisq/pull/5577/hovercard" href="https://github.com/bisq-network/bisq/pull/5577">#5577</a>, which should be reviewed and merged before this one.</p>

<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/5659'>https://github.com/bisq-network/bisq/pull/5659</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Refactor EditOfferDataModel for new editoffer api method</li>
  <li>Fix comment</li>
  <li>Add OfferInfo field isActivated, rpc EditOffer to proto</li>
  <li>Add server/core editOffer, adjust getMyOffer(s) impls</li>
  <li>Refactor GrpcClient: request builders moved bisq.cli.request pkg</li>
  <li>Add new EditOfferOptionParser and test</li>
  <li>Add editoffer method help</li>
  <li>Add editoffer to CLI</li>
  <li>Add editoffer api tests & minor apitest refactoring</li>
  <li>Remove chase quickpay acct test</li>
  <li>Remove unused import</li>
  <li>Fix problems found in codacy check</li>
  <li>Fix codacy issue</li>
  <li>Fix log arg spec bug</li>
  <li>Add bool isMyOffer to OfferInfo proto</li>
  <li>Fix editoffer validation bugs, tidy up CoreOffersService</li>
  <li>Show enable/trigger-price cols for 'getmyoffer'</li>
  <li>Improve 'editoffer' opt parsing, fix test pkg name</li>
  <li>Add editoffer test case, suppress annoying warnings</li>
  <li>Remove unused field</li>
  <li>Throw exception is edit altcoin offer is attempted</li>
  <li>Avoid duplicate test run</li>
  <li>Make codacy just a bit happier</li>
  <li>Force codacy check after codacy config change</li>
  <li>Include isMyOffer flag in API's trade/offer proto wrappers</li>
  <li>Pass isMyOffer flag to trade/offer proto wrappers from core services</li>
  <li>Add altcoin (bsq) offer editing validation check</li>
  <li>Optionally show ENABLED column in CLI's getoffer(bsq) output</li>
  <li>Add BSQ offer editing tests to EditOfferTest</li>
  <li>Merge branch 'master' into 02-refactor-for-api-editoffer-method</li>
  <li>Merge branch '02-refactor-for-api-editoffer-method' into 03-api-editoffer-method</li>
  <li>Merge branch '03-api-editoffer-method' into 04-edit-bsq-offer</li>
  <li>Force rebuild after github action ECONNRESET</li>
  <li>Document api 'editoffer' usage</li>
  <li>Fix header</li>
  <li>Delete tmp main() method</li>
  <li>Rename and move private function</li>
  <li>Do not duplicate Price.parse on CLI side for only one use case</li>
  <li>Remove old TODO because relevant refactoring was approved</li>
  <li>Fix typo 'enabled' -> 'enable'</li>
  <li>Always use Locale.US in CLI DecimalFormats</li>
  <li>Merge branch 'master' into 05-update-api-beta-test-guide</li>
  <li>Do not start test harness deamons in dbg mode by default</li>
  <li>Add missing trigger-price param</li>
  <li>Fix peer add(offer) & remove(offer) event order problem</li>
  <li>Revert "Fix peer add(offer) & remove(offer) event order problem"</li>
  <li>Merge branch 'master' into 05-update-api-beta-test-guide</li>
  <li>Ensure UI OfferBook items are correctly added and removed</li>
  <li>Revert logback debug config changes</li>
  <li>Merge branch 'master' into 06-safe-offerbook-add-remove-events</li>
  <li>Remove comment (question answered)</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-6a54058c81f798cd70d475e511e3afa76c3c8b629529065c5f099176f3b47324">apitest/docs/api-beta-test-guide.md</a>
    (114)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-c635a83c621d11fe469b4c85a89da2dc19300fd7048b1260d33cd5dc64ddd817">apitest/src/test/java/bisq/apitest/method/offer/AbstractOfferTest.java</a>
    (56)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-e9afaf25a040818933ead2d35a47a8cfdbedfe645b5a20032150280683f6ddc0">apitest/src/test/java/bisq/apitest/method/offer/CancelOfferTest.java</a>
    (3)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-95eb2e15e7182812f9c4518c5cbbb38d3c6fbb4ca8388f4600a5c1541ad29691">apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java</a>
    (57)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-c509b6ac7a6e233bdce7b899a481d6f2d310495356be8025e8296481bca6decb">apitest/src/test/java/bisq/apitest/method/offer/EditOfferTest.java</a>
    (644)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-80fde285109a91d7581e771828393b6c87ac3b2a7e7de6ee750e7d41e594650a">apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferTest.java</a>
    (3)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-5b8b6ad84050dec238d10e9467ec7dafab6967d7e8f0a49bab65c43ee38532c8">apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferWithNationalBankAcctTest.java</a>
    (3)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-0a94ee487ea9d0b7b440b8688f6e9df897fd089fc84ead5f6cc9ca9453ad3b21">apitest/src/test/java/bisq/apitest/method/trade/TakeSellBTCOfferTest.java</a>
    (3)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-8ec418fbbeef108d5131d09db3e2d6a399900e03c90578db7d8685f73ab88c61">apitest/src/test/java/bisq/apitest/scenario/LongRunningOfferDeactivationTest.java</a>
    (167)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-9821c6377844d8a676dbeb322769c02a88430d0855752ea23a660b1dce2a9465">apitest/src/test/java/bisq/apitest/scenario/OfferTest.java</a>
    (30)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-f661c3bd0385dafccef63c304b78674c5e3e1305f663885c97daf05bf6ad6257">apitest/src/test/java/bisq/apitest/scenario/bot/BotClient.java</a>
    (11)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-7fdd0ca2025f77ccbebb1cd6636ce3b348793ac7d35aaaed30f2bc8edc53d74d">apitest/src/test/java/bisq/apitest/scenario/bot/RandomOffer.java</a>
    (9)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-afc5db1c8acb08dec253ee87a3e0e677c932d6826a2ab4c31ba816a4dcfb1386">cli/src/main/java/bisq/cli/CliMain.java</a>
    (42)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-9687777eeb1474070ca4255e431cc57c81fd0988ae088aaaf980aa7600f21b9d">cli/src/main/java/bisq/cli/ColumnHeaderConstants.java</a>
    (3)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-bc03e9b04d52b37f48d4f56aa608b4a50a2085dff40f9fc738d910ea5a72d599">cli/src/main/java/bisq/cli/CurrencyFormat.java</a>
    (75)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-ae5b5d0bb9a18998e885050698a2ce8dde809059fffc344f1d24a937e6ecbae3">cli/src/main/java/bisq/cli/GrpcClient.java</a>
    (377)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-330baed45084180eea99af5e846a1c064bb8cebde98bcc24ad1c04d00efcb5b8">cli/src/main/java/bisq/cli/Method.java</a>
    (1)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-2ac1e865aee578e0d675f0b5777c3c9ba660b165166cb7b031539face84c8559">cli/src/main/java/bisq/cli/TableFormat.java</a>
    (185)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-81d1e9d20597797e7e7362edb885afae00c219a7b9ad04167c265945adc767c3">cli/src/main/java/bisq/cli/opts/AbstractMethodOptionParser.java</a>
    (4)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-be7c0421fc919918d0ef150748a177731e56d8754ce45ba09070c6a28b7652bb">cli/src/main/java/bisq/cli/opts/EditOfferOptionParser.java</a>
    (281)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-c3491a41f640da451ad42a12869b1f6552f22c2fb56da31eeb1c01498a8b8203">cli/src/main/java/bisq/cli/opts/OptLabel.java</a>
    (2)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-4e8c0dfbccf8d462e6d9b506f60ec6a0fcf6ec6d948a830a0319f535b6273a68">cli/src/main/java/bisq/cli/request/OffersServiceRequest.java</a>
    (319)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-4d8e7b98c8ea2d4c217008f86c97a1f65cf138557745bd52474c38d4386b971f">cli/src/main/java/bisq/cli/request/PaymentAccountsServiceRequest.java</a>
    (85)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-ad3170ab7cde237c109c2a6976774bb1ef54a9b597c0e40dc01ab505e0c25f62">cli/src/main/java/bisq/cli/request/TradesServiceRequest.java</a>
    (94)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-5ea9c900e9b8b10fab66da64476b82fa79faab0bdc6dfccf9a5238c2fc44a9b8">cli/src/main/java/bisq/cli/request/WalletsServiceRequest.java</a>
    (192)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-6e81fa5360ae872af51f035bcc20fd72e4086c0f9d4e4080428c4c0684244e1c">cli/src/test/java/bisq/cli/opts/EditOfferOptionParserTest.java</a>
    (346)
  </li>
  <li>
    <strong>R</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-ede07c8bd4b1fa3a239f204d2755a98f4aa7169b6acda7d2acebc2e6f9e0cf05">cli/src/test/java/bisq/cli/opts/OptionParsersTest.java</a>
    (11)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-fb5876d3b212d239a14d78529ac498b30a2dbb8e3f184ba9bd711a5d4901fb62">core/src/main/java/bisq/core/api/CoreApi.java</a>
    (47)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-e66126b732dbd45cde04307641186caa214407bc74403812b10d3ebf18d2aecc">core/src/main/java/bisq/core/api/CoreOffersService.java</a>
    (193)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-410e4a9ca8e6f5e3cfdd5c062c19512e63fa38a82b1247f91ef29ed385f34d1b">core/src/main/java/bisq/core/api/EditOfferValidator.java</a>
    (141)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-3a9ff7695726e0660444b5b5e18600d2cff2bc2fcdf3f78c36a0fc3df504e1b6">core/src/main/java/bisq/core/api/model/OfferInfo.java</a>
    (45)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-5751067b75ae6f7739df840d815386f3998f04baff5de96c079f5ce1fe6b4f57">core/src/main/java/bisq/core/api/model/TradeInfo.java</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-0627a2f42073fe18d535206646c77be244e8965a0ee0ef0cb8b15acd5d2effe8">core/src/main/java/bisq/core/notifications/alerts/market/MarketAlerts.java</a>
    (6)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-097028e83b2494ec6c56ccd77cb7aadadcbdc179233003a99605bd02ab3f76af">core/src/main/java/bisq/core/offer/MutableOfferPayloadFields.java</a>
    (89)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-84757b6093f3f1709fd2066f843d0342f0ebbf6d8ec0f5406fd6f6282f42042e">core/src/main/java/bisq/core/offer/OfferBookService.java</a>
    (22)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-b604ee7141fcfacf2dd0aeade4bf393c4d4d93617ab327147c363539ae804496">core/src/main/java/bisq/core/offer/OfferUtil.java</a>
    (47)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-8117d541d1fe0e9008d17a7cb5c9b944c83e92c280748e5ef6de5c057a355e3c">core/src/main/resources/help/editoffer-help.txt</a>
    (95)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-5afef68b74948ae40e71a3955d52c1bfd52fa4a95fed271c6cae61626089073d">daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java</a>
    (31)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-0999abe6a76f18c5be810b6c5436cea6d708c11d99ed316d0397c3ebbc6aa777">daemon/src/main/java/bisq/daemon/grpc/GrpcTradesService.java</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-7d6cae9fee25a6cf61af1d755dba63c84d60e50c77c18a276c2618983a36310a">desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java</a>
    (161)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-140495eef332912128cac981479058838937d7fcabef4498f9fffd08d1e2df39">desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookListItem.java</a>
    (45)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-e91ddc497f0b94a9a80cc234cbdcedaf05e8f40e6e1d5fc7e9c9794f97063495">desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-41b34a44d2df26644ec2e93e7c7211540603530d5d8649b0545ec4963b5315d5">desktop/src/main/java/bisq/desktop/main/portfolio/editoffer/EditOfferDataModel.java</a>
    (49)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-010fcf0227335959cb52c09b78f23e5d86d26a9d2c7ca37b023645a7fcee6502">desktop/src/main/resources/logback.xml</a>
    (1)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/5659/files#diff-dcb44a0045a5b02cde5bd2f45051b7d9293f87180111c7ea57f0d0eb85d0f393">proto/src/main/proto/grpc.proto</a>
    (33)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/bisq-network/bisq/pull/5659.patch'>https://github.com/bisq-network/bisq/pull/5659.patch</a></li>
  <li><a href='https://github.com/bisq-network/bisq/pull/5659.diff'>https://github.com/bisq-network/bisq/pull/5659.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/5659">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNWCHZRRXKUULMUVMO3T4KD6HANCNFSM5B6V23YQ">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email">Android</a>.<img src="https://github.com/notifications/beacon/AJFFTNXW2BUKO5F4V4G7JK3T4KD6HA5CNFSM5B6V23Y2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ONA753A.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/5659",
"url": "https://github.com/bisq-network/bisq/pull/5659",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>