RGB-WG / rgb-std

RGB standard libs for WASM & low-level integrations (no FS/networking)
https://rgb.tech
Apache License 2.0
66 stars 28 forks source link

accepting a consignment for a 0-conf TX doesn't show allocations #266

Closed zoedberg closed 3 months ago

zoedberg commented 3 months ago

After recent updates (between beta 5 and 7) the behavior of accept_transfer changed.

By running cargo test --test transfers accept_0conf -- --nocapture on this branch, you'll see that after the receiver wallet accepts a consignment related to a TX in mempool it will not see the new allocations.

Without mining (after the broadcast) the receiver will see:

amount=600, utxo=bc:opret1st:e1061a9a463fa2625b896932040f34cc183b3da0d99ee2574ed2709ab996c1dc:1, witness=None # owner unknown

If we instead mine a block the receiver will see:

amount=200, utxo=bc:opret1st:7d5011715ff24b44f4226aab4ab3420a088e16d54959bc029c91167ff730f4e9:0, witness=Some(Bitcoin(Array<32>(7d5011715ff24b44f4226aab4ab3420a088e16d54959bc029c91167ff730f4e9))) # owned by the wallet
amount=400, utxo=bc:opret1st:7d5011715ff24b44f4226aab4ab3420a088e16d54959bc029c91167ff730f4e9:1, witness=Some(Bitcoin(Array<32>(7d5011715ff24b44f4226aab4ab3420a088e16d54959bc029c91167ff730f4e9))) # owner unknown
amount=600, utxo=bc:opret1st:2834670aa03354e756fd0ea5e3f6e1823049de378975516564e25a770b6d3018:1, witness=None # owner unknown

We noticed this while trying to update RLN to RGB beta 7, where the channel acceptor is unable to create the first pair of commitments (the ones created before the funding gets broadcasted). Therefore the fix for this should not only allow seeing the allocations of a 0-conf TX but also of an unbroadcasted one.

dr-orlovsky commented 3 months ago

I think this is related to the problem with detecting mempool tx as Tentative in some indexers, which we discussed before. Which indexer do you use in the failed test? Does it work with other indexers?

zoedberg commented 3 months ago

Good hint, I forgot about that. With electrum the test is behaving as expected (showing allocations even if TX has 0 confirmations). I've opened https://github.com/RGB-WG/rgb/pull/241 to make esplora behave the same as electrum.

For unbroadcasted TXs we'll write a custom resolver in RLN. So after merging the PR this issue can be closed.