mastercoin-MSC / mastercore

mastercore info
mastercoin.org
MIT License
24 stars 11 forks source link

Cancel-at-price: "Not enough funds in user address" #217

Closed dexX7 closed 9 years ago

dexX7 commented 9 years ago

1) A1 starts with 50.0 TMSC, 0 TIndiv1 2) A1 offers 50.0 TMSC for 100 TIndiv1 3) A1 cancels 50.0 TMSC for 100 TIndiv1 (cancel-at-price)

This fails with the message "Not enough funds in user address".

Related test lines: test_cancel_at_price.py#L307-L356

zathras-crypto commented 9 years ago

Thanks DexX, not sure what's going on here - great testing :)

dexX7 commented 9 years ago

It probably comes from mastercore::send_INTERNAL_1packet and it looks like as if the user's balance would be used for a check like this:

  1. Start: 50.0 available, 0.0 reserved
  2. Create: 0.0 available, 50.0 reserved
  3. Cancel: fail, because available < amount-to-cancel

The "cancel" seems to be treated as "send", thus a check against the balance. What makes me wonder a bit: "cancel-pair" and "cancel-everything" is explicitly excluded as it seems, but a "cancel-at-price" not. (mastercore.cpp#L2908)

ghost commented 9 years ago

Good catch Dexx, I think this was due to an erroneous assumption on my part (that the user actually needed to check if they had the funds for any cancel - which is not needed)

Added cancel-price to exclusions list, and renamed variables: https://github.com/mastercoin-MSC/mastercore/pull/221/files

dexX7 commented 9 years ago

@faizkhan00: I'm testing the current master and it seems the test still fails, but based on some other effect:

The cancel itself seems to have no effect anymore.

This is limited to the special case where "amount-to-cancel" > "available-balance" and the other tests of cancel-at-price finish as expected.


1) A1 starts with 50.0 TMSC, 0 TIndiv1:

Orderbook: empty Balance: 50.0 TMSC available, 0.0 TMSC reserved

2) A1 offers 26.0 TMSC for 100 TIndiv1

Orderbook: 26.0 TMSC offered for 100 TIndiv1 Balance: 24.0 TMSC available, 26.0 TMSC reserved

3) A1 cancels 26.0 TMSC for 100 TIndiv1 (cancel-at-price):

Orderbook: 26.0 TMSC offered for 100 TIndiv1 Balance: 24.0 TMSC available, 26.0 TMSC reserved

dexX7 commented 9 years ago

This was fixed by #221 and #222.