slimcoin-project / pacli

Simple CLI PeerAssets client (extended version).
GNU General Public License v3.0
0 stars 0 forks source link

Unexistent transactions on successful run of the attoken spawn command. #185

Closed buhtignew closed 2 months ago

buhtignew commented 2 months ago

I've run attoken spawn johns_attoken3 mgpiP2Dc5QweKFS55HvRqsWyQ6PMXJCVCk -f 538869 -e 638868 -c n3MtPoPaAREU5GEhAErBPuju83bVog2opz and attoken spawn johns_attoken3 mgpiP2Dc5QweKFS55HvRqsWyQ6PMXJCVCk -f 538869 -e 638868 -c n3MtPoPaAREU5GEhAErBPuju83bVog2opz -d And have produced 0e04a38392b99e0b3b53445b93ece8ad721c8ee7d72b037d1fcc3a2ad8ab4712 and 069ea610b6045bfd18766048374010181bf561caf0b664574db337ac73b076a4 transactions. However I was not able to see those decks in the token list -a output. So I've tried transaction show 0e04a38392b99e0b3b53445b93ece8ad721c8ee7d72b037d1fcc3a2ad8ab4712 -s and transaction show 069ea610b6045bfd18766048374010181bf561caf0b664574db337ac73b076a4 -s and got:

Error: Transaction does not exist or is corrupted.

I've run attoken send_coins mie75nFHrNAHHKfQ141fWfWozdMnaec8mb 1 and pobtoken spawn my3 -f 538869 -e 638869 -c n3MtPoPaAREU5GEhAErBPuju83bVog2opz and these commands have produced regular transactions (65afc44b9ec94ec6ebcd8733817f490f1b58906a1cfcf1142ee86cbd8be294b1 and 5b15a52c08554c2f3859fb274338622d52ce6702e2fcaca73e63ab445f1c29f1).

d5000 commented 2 months ago

Indeed these transactions (0e04a38392b99e0b3b53445b93ece8ad721c8ee7d72b037d1fcc3a2ad8ab4712 and 069ea610b6045bfd18766048374010181bf561caf0b664574db337ac73b076a4) are not confirmed, I don't see them. Do you see them in your mempool? (slimcoind getmemorypool)?

If not, then the transactions were probably created but invalid. It would then be helpful if you run the spawn commands again and if the transactions don't confirm, then post the transaction hex strings, so I can see if there is something preventing the transactions from being confirmed.

buhtignew commented 2 months ago

Here is my slimcoind getmemorypool output:

{
    "version" : 1,
    "previousblockhash" : "0000003cb67a96c458a0ea9108db8f94694c51008f37a0a18a026447e5ef3212",
    "transactions" : [
    ],
    "coinbasevalue" : 12210000,
    "coinbaseflags" : "062f503253482f",
    "time" : 1726216711,
    "mintime" : 1726215956,
    "curtime" : 1726216711,
    "bits" : "1e00e932"
}

Here are the transaction hex strings of the above mentioned transactions:

d5000 commented 2 months ago

I've seen the problem already: Both transactions have an output with a value of 0 SLM. This is not allowed by the protocol.

I will investigate, that looks like a bug.

UPDATE: I could reproduce the bug and the problem seems to be located in the core of pypeerassets. The problem will appear if you have outputs which sum exactly 0.03 coins (often happens when "grabbing" P2TH outputs), which is the exact needed value for the transaction normally, but it will afterwards create an additional output with 0 coins.

d5000 commented 2 months ago

Fixed in pypeerassets commit 4d15fb9. The program was creating a change output always, even if the change was zero. This has been modified now in a way that only if the input volume is greater than the outputs + fees, a change output is created.

Steps to reproduce and test the bug:

Have pre-tested it, the problem no longer occurred. So it can be closed.

buhtignew commented 2 months ago

I've tested it, seems to work.

The only doubt I have is that the address I've been spawning the tokens from (n3MtPoPaAREU5GEhAErBPuju83bVog2opz) has 3169.874 coins right now and it had enough coins to spawn tokens because I've been able to spawn attokens afterwards, as you can see from the OP.

d5000 commented 2 months ago

Yes, the case that 0.03 are taken as an input can also happen if the address has outputs with more coins on it. The PeerAssets coin selection algorithm is quite complex and has several criteria. It can even "grab" coins which are "on other addresses" in your wallet, and so in the deck spawns you posted in this issue that didn't work it "grabbed" P2TH fees from the P2TH addresses.

In the cases I did the two steps I listed in the last post however it worked as expected: the algorithm took exactly these 0.03 coins I had transferred and created a deck spawn transaction from it, with only 2 outputs (P2TH and OP_RETURN), with no additional change output added.

The bug was also quite obvious so testing is not really needed.