5

I always assumed that this could not make its way into the ledger, but while testing with (seemingly) invalid transactions, I created the following:

A custom asset

I created a custom asset. As you can see in the lab explorer, I issued an amount of 4000 units.

I funded a new account

A simple account with a little amount of the asset

I created a transaction for the account to send itself much more of the asset that it owns

Actually, way more of the asset than actually exists. There were 4000 issued, but I sent a payment over 12312312313.0000000.

You can see the operation here.

Good thing: It did not actually get applied

When we look at the account we see that I was not able to overspend.

Confusing: Why was this transaction successful and made it into the ledger?

The transaction containing the operation was successful. You can also see this in the result XDR.

This is confusing to me. I would have assumed that this would not be accepted into the ledger. I would be very grateful for some hints, why this happened :)

2 Answers 2

4

You can say the transaction makes it into the ledger because the operations in the transaction are themselves balanced.

The main confusion is the example is transferring the amounts within itself.

If you start with 100 Apples in the account, then send 10,000,000 Apples (-10,000,000) to the account, and receive 10,000,000 Apples (+10,000,000) from the account in the same operation, on a net basis, the operation is a +0 increase and -0 decrease to the balance of the account; leaving you with 100 Apples. You said the transaction "didn't take effect" I say "it did take take effect; you spent 10,000,000 and received 10,000,000 in the same operation".

What makes this operation different is that it is operating on itself and therefore the additions and deductions net out to a value the account balance actually has (the same amount it started with).

2
  • 1
    Thank you for the explanation, this makes sense to me in a technical way. However, I still think this is confusing behaviour, I would have expected an OP_UNDERFUNDED error, like with any other payment that is overspending.
    – chris_b
    Commented May 14, 2018 at 5:17
  • It's definitely arguable, and I agree with the sentiment that it's not intuitive, and possibly shouldn't be valid. However if you ordered the application of the effects so that you first increase to the receiver's account (+10,000,000 units), then you deduct from the sender's account (-10,000,000 units); then you wouldn't hit an OP_UNDERFUNDED error. In general, my experience of finance applications is that they tend to do things in that order.
    – MikeFair
    Commented May 15, 2018 at 1:14
1

It's in the ledger because even though the transaction didn't succeed in the way you wanted it to, you still forced the network process your transaction - thus, your account needed to be charged the XLM fee for the transaction (see the fee_paid property in the transaction results).

If you compare your "native" (i.e. XLM) balance from before and after the transaction, you should see that it decreased by 100 stroops.

Hope that helps!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.