mastercoin-MSC / mastercore

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

Balance query calls, zero balances and exceptions #267

Closed dexX7 closed 9 years ago

dexX7 commented 9 years ago

When retireving a balance for an address and a property, there are basically the following scenarios and combinations thereof:

Properties:

Balances:

The current behavior is as follows, IIRC:

  1. If the property doesn't exist, an exception is thrown.
  2. If the user has never interacted with the property, an exception is thrown as well.
  3. If the user had some balance in the past, but has a zero balance at the moment, a zero balance is returned.
  4. If the user has some balance right at the moment, the balance is returned.

I left out the obvious case: wrong user input, say for example an out-of-range property id is provided. In this case without a doubt an exception should be thrown.

Now what I'm wondering about is basically: is it really an exceptional situation, if the user has never transacted with a property? Is it an exceptional situation, if the property doesn't exist? How does it matter, whether there was some previous transaction involving a property or not?

It can be said: a user has a zero balance of X, in any case, whether X exists or was interacted with in the past. It's a fine line and probably application dependant what the right route is, but I'm interested in your opinion.

Edit: how is *never defined here? Edit: unconfirmed transactions are not supported and "do not really exist", bluntly said.

dexX7 commented 9 years ago

Side note: While probably not directly related, I opened this issue in the context of https://github.com/mastercoin-MSC/omniwallet/issues/1184#issuecomment-68361027. (ping @achamely)

m21 commented 9 years ago

@zathras-crypto may chime in too, for masterchest's sake in the key integrator role :)

zathras-crypto commented 9 years ago

If the user has never interacted with the property, an exception is thrown as well.

Disagree mate, we only ever check previous interaction for getall functions. Eg getbalance_MP on a never used property:

zathras@coredev01:~/github/build/mastercore$ src/mastercored getbalance_MP 1zAtHRASgdHvZDfHs6xJquMghga4eG7gy 6
{
    "balance" : "0",
    "reserved" : "0"
}

Is it an exceptional situation, if the property doesn't exist?

Yes, in my opinion. Core only shows properties that exist as showing you have a zero balance of ZathrasCoins incorrectly implies ZathrasCoins exist in the first place.

dexX7 commented 9 years ago

Disagree mate, we only ever check previous interaction for getall functions.

Ah right, I mixed the bahavior with https://github.com/mastercoin-MSC/mastercore/issues/93 (gettransaction_MP throws exception, if transaction is unconfirmed).

In this case I agree with current behavior, and in particular regarding non-existing properties.