<p>I had a closer look.</p>
<p>bitcoinj was not built to work with multiple wallet instances.<br>
A couple of fixes where made, but there is no comprehensive solution.<br>
On one side there is the problem of shared Transaction, TransactionInput and TransactionOutput instances.<br>
But then we have TransactionConfidence instances which live in TxConfidenceTable and there is only one TxConfidenceTable per Context.</p>
<p>So,</p>
<ul>
<li>cloning the tx on receivePending() is a step forward. Minor performance improvement: I would move the cloning instruction to be executed after all the checks passed, ie just before commit() is executed.</li>
<li>I suggested reverting a couple of commits. I was wrong. Even if the Transaction is cloned, TransactionConfidence instance is still shared, so those commits should not be reverted.</li>
<li>I am evaluating what a comprehensive solution would need. I am looking closely at Wallet's receivePending(), receiveFromBlock(), notifyTransactionIsInBlock(), commitTx(), maybeCommitTx(), reorganize(), receive(), addWalletTransaction(pool, tx) and addWalletTransaction(WalletTransaction wtx) methods to check whether more fixes are necessary. I am thinking whether a bitcoinj refactor is necessary, maybe each wallet may have its own TxConfidenceTable... just thinking out loud. I will post again after I finish my investigation.</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/bitcoinj/pull/18#issuecomment-450700067">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AkpZtssqJuWobs7WSwdh7C2NSGLO-SA3ks5u-qSMgaJpZM4Zgibw">mute the thread</a>.<img src="https://github.com/notifications/beacon/AkpZtpvaR_QMUqW7wX0RnAOujKekRA4uks5u-qSMgaJpZM4Zgibw.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/bisq-network/bitcoinj","title":"bisq-network/bitcoinj","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/bisq-network/bitcoinj"}},"updates":{"snippets":[{"icon":"PERSON","message":"@oscarguindzberg in #18: I had a closer look.\r\n\r\nbitcoinj was not built to work with multiple wallet instances.\r\nA couple of fixes where made, but there is no comprehensive solution.\r\nOn one side there is the problem of shared Transaction, TransactionInput and TransactionOutput instances.\r\nBut then we have TransactionConfidence instances which live in TxConfidenceTable and there is only one TxConfidenceTable per Context.\r\n\r\nSo,\r\n- cloning the tx on receivePending() is a step forward. Minor performance improvement: I would move the cloning instruction to be executed after all the checks passed, ie just before commit() is executed. \r\n- I suggested reverting a couple of commits. I was wrong. Even if the Transaction is cloned, TransactionConfidence instance is still shared, so those commits should not be reverted.\r\n- I am evaluating what a comprehensive solution would need. I am looking closely at Wallet's receivePending(), receiveFromBlock(), notifyTransactionIsInBlock(), commitTx(), maybeCommitTx(), reorganize(), receive(), addWalletTransaction(pool, tx) and addWalletTransaction(WalletTransaction wtx) methods to check whether more fixes are necessary. I am thinking whether a bitcoinj refactor is necessary, maybe each wallet may have its own TxConfidenceTable... just thinking out loud. I will post again after I finish my investigation.\r\n\r\n\r\n"}],"action":{"name":"View Pull Request","url":"https://github.com/bisq-network/bitcoinj/pull/18#issuecomment-450700067"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bitcoinj/pull/18#issuecomment-450700067",
"url": "https://github.com/bisq-network/bitcoinj/pull/18#issuecomment-450700067",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>