elective-stereophonic
elective-stereophonic
Reference Transaction: Insufficient Balance singapore
Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Stable Nxt Client: Nxt 1.11.15 | Latest Experimental Nxt Client: Nxt 1.12.0e

Author Topic: Reference Transaction: Insufficient Balance  (Read 3578 times)

websioux

  • Sr. Member
  • ****
  • Karma: +69/-1
  • Offline Offline
  • Posts: 343
  • Great changes grow bottom up
    • View Profile
    • Scriba.io the Blockchain Scribe
Reference Transaction: Insufficient Balance
« on: September 15, 2016, 12:23:48 pm »

I think I need your eyes if not a new understanding. I'm trying to send a transaction with API and it returns "insufficient balance" error.. while.. it should not.

Look at this :

Code: [Select]
curl -sk --data "requestType=getAccountId&secretPhrase=Sorry_but_I_can_not_tell_you_what_it_is"  http://127.0.0.1:7876/nxt
Quote
{   "accountRS":"NXT-3D2L-CCSX-487E-GM8FP",
   "publicKey":"fe02e857b7018caf925020c0f1ca811f53256dc86266da7c0654b185ac7cfc02",
   "requestProcessingTime":2,
   "account":"16912374852807076882"
}

Code: [Select]
curl -sk --data "requestType=getAccount&account=NXT-3D2L-CCSX-487E-GM8FP" http://127.0.0.1:7876/nxt
Quote
{   "unconfirmedBalanceNQT":"62299999668",
   "accountRS":"NXT-3D2L-CCSX-487E-GM8FP",
   "forgedBalanceNQT":"0",
   "balanceNQT":"62299999668",
   "publicKey":"fe02e857b7018caf925020c0f1ca811f53256dc86266da7c0654b185ac7cfc02",
   "requestProcessingTime":0,
   "account":"16912374852807076882"
}

Code: [Select]
curl -sk --data "requestType=sendMoney&recipient=NXT-SL44-R65Z-HMNZ-7WVJM&amountNQT=55300000000&secretPhrase=Sorry_but_I_can_not_tell_you_what_it_is&deadline=2880&referencedTransactionFullHash=3d542da2b77a219c8427d1df35b400c58345c7fbfabead74b55402450bbd2068&encryptedMessageData=8eab8c3c3f1033eff28d17acf025055618df9208c877ba2a9b6049db6fc71a1c3dfab6b6429f72079708135a39be8345955874800845d0300037a5ea7ffcc20c4f4960a59747f39ad1261250e002c273d7eb7e2d899da0b69beed5a7cd213f0f4434b8da947f1d3710bd0b9ec545bcf98b9f2d4dcc3e9f9b98a6e99d4a08527488c556e44525204dc9fb6c766cb3d3b79641f30f966a821d9bfbfcf630e471caf0e9987d8dfbc19a668519c0e254ed3de4e2bb6436995670f0b94fe84e0e46b7&encryptedMessageNonce=07bdb2a1e481c69ce1ed144d0982ca276fd4456763a6dfe250faf5b4410d5279&encryptedMessageIsPrunable=true&feeNQT=200000000" http://127.0.0.1:7876/nxt
Quote
{   "errorDescription":"Insufficient balance",
   "errorCode":4,
   "error":"nxt.NxtException$InsufficientBalanceException: Insufficient balance"
}

So the passphrase corresponds to Account NXT-3D2L-CCSX-487E-GM8FP which as a balance of 62299999668 NQT but API tells it can not spend 5530000000 + 20000000 (fees)

I have double check passphrase and amounts, and can not find out what is going on.
Any help is welcome. I can MP the passphrase if necessary.

« Last Edit: September 16, 2016, 10:44:25 am by websioux »
Logged
Secret Miner <= communicate with style | NotBot <= timestamp digital docs

Riker

  • Core Dev
  • Hero Member
  • *****
  • Karma: +439/-42
  • Offline Offline
  • Posts: 1796
    • View Profile
Re: Insufficient Balance Error I can't understand
« Reply #1 on: September 15, 2016, 12:59:42 pm »

From quickly looking at the code I see that the referenced transaction adds 100 NXT to the required fee.
TransactionType.java line 212
Logged
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

websioux

  • Sr. Member
  • ****
  • Karma: +69/-1
  • Offline Offline
  • Posts: 343
  • Great changes grow bottom up
    • View Profile
    • Scriba.io the Blockchain Scribe
Re: Insufficient Balance Error I can't understand
« Reply #2 on: September 15, 2016, 01:50:45 pm »

oups! I started to find referenced transaction awesome to guarantee a chain of inclusion.... but at 100 Nxt extra I have to recalculate the risk ;-)

ok so I guess on TransactionType.java line 214
feeNQT = Math.addExact(feeNQT, Constants.UNCONFIRMED_POOL_DEPOSIT_NQT);
should be replaced by
feeNQT = Math.addExact(feeNQT, Constants.ONE_NXT);
Logged
Secret Miner <= communicate with style | NotBot <= timestamp digital docs

Riker

  • Core Dev
  • Hero Member
  • *****
  • Karma: +439/-42
  • Offline Offline
  • Posts: 1796
    • View Profile
Re: Insufficient Balance Error I can't understand
« Reply #3 on: September 15, 2016, 02:03:57 pm »

As explained in the change log:
"To prevent denial of service attacks, transactions that need to stay in the
unconfirmed transactions pool, while waiting for their referenced transactions
to arrive, will be charged 100 NXT refundable deposit. This is subtracted from
the unconfirmed balance of the account when the transaction is accepted into the
unconfirmed pool, and is refunded back when the transaction is either confirmed,
or expires and is removed from the pool."
Logged
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

websioux

  • Sr. Member
  • ****
  • Karma: +69/-1
  • Offline Offline
  • Posts: 343
  • Great changes grow bottom up
    • View Profile
    • Scriba.io the Blockchain Scribe
Re: Insufficient Balance Error I can't understand
« Reply #4 on: September 15, 2016, 02:26:37 pm »

"while waiting for their referenced transactions to arrive"

What does "to arrive" mean?

Here the referenced transaction 11250408273266693181 (fullhash: 3d542da2b77a219c8427d1df35b400c58345c7fbfabead74b55402450bbd2068) has already arrived.

It is because I see it in the ledger that I treat it. And because it has an error with the attached message order number that I want to refund it (minus the fees).
Referenced transaction allows me that I will not send the money if for some unlucky blockchain reorg reason the original transaction, who mistakenly sent the funds, would expire.

So this transaction does not "need to stay in the unconfirmed transactions pool".
Logged
Secret Miner <= communicate with style | NotBot <= timestamp digital docs

Riker

  • Core Dev
  • Hero Member
  • *****
  • Karma: +439/-42
  • Offline Offline
  • Posts: 1796
    • View Profile
Re: Insufficient Balance Error I can't understand
« Reply #5 on: September 15, 2016, 07:41:21 pm »

"while waiting for their referenced transactions to arrive"

What does "to arrive" mean?

Here the referenced transaction 11250408273266693181 (fullhash: 3d542da2b77a219c8427d1df35b400c58345c7fbfabead74b55402450bbd2068) has already arrived.

It is because I see it in the ledger that I treat it. And because it has an error with the attached message order number that I want to refund it (minus the fees).
Referenced transaction allows me that I will not send the money if for some unlucky blockchain reorg reason the original transaction, who mistakenly sent the funds, would expire.

So this transaction does not "need to stay in the unconfirmed transactions pool".

Why don't you used phased transaction with a linked transaction hash ?

See the following paragraph in the changelog:
"Finally, it is possible to make a phased transaction that is released or
rejected not on the basis of voting, but based on the presence of other
transactions (linked transactions) in the blockchain at its finish height.
To do that, up to 10 phasingLinkedFullHash transaction hashes can be defined
when creating the phased transaction. Note that this does not create a
dependency between the linked transactions themselves. This feature can be
used to implement atomic execution of transactions of any type, provided the
phased transaction is phasing safe. Transactions already in the blockchain
before the acceptance of the phased transaction can also be linked, as long
as they are not more than 60 days old, or themselves phased transactions."
Logged
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

websioux

  • Sr. Member
  • ****
  • Karma: +69/-1
  • Offline Offline
  • Posts: 343
  • Great changes grow bottom up
    • View Profile
    • Scriba.io the Blockchain Scribe
Re: Insufficient Balance Error I can't understand
« Reply #6 on: September 16, 2016, 07:26:01 am »

Why don't you used phased transaction with a linked transaction hash ?

Because referenced transaction feature seemed to be created to specifically serve that purpose. So I may try phased transaction with a linked transaction hash. Which, indeed, should do the job. Thanks.

But I now realize that the 100 Nxt are not a cost but a REFUNDABLE DEPOSIT. So I could use that too, I just need enough fund. And I guess that is what has added to my confusion because I made some other referenced transaction that seemed not to need this 100 Nxt. But I now understand that it needed it, the account had it, paid it, had it refunded, without me noticing it.

Looking at the code, I understand that the deposit is always taken regardless of the presence of the transaction which is referenced. Which makes sense.

If this is true, the part of the change log that says :

Quote
"transactions that need to stay in the unconfirmed transactions pool, while waiting for their referenced transactions to arrive,"

..would have better not been there or not written this way. It is the reason why a DOS attack could succeed but not the condition to decide if the deposit is charged.

Can you confirm my understanding? then the case is closed ?
Logged
Secret Miner <= communicate with style | NotBot <= timestamp digital docs

Riker

  • Core Dev
  • Hero Member
  • *****
  • Karma: +439/-42
  • Offline Offline
  • Posts: 1796
    • View Profile
Re: Insufficient Balance Error I can't understand
« Reply #7 on: September 16, 2016, 09:14:42 am »

Correct. The 100 nxt is a refundable deposit. I still recommend that you use phasing and not referenced transactions if you can since it is more secure and flexible.

Sent from my LG-D855 using Tapatalk

Logged
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

websioux

  • Sr. Member
  • ****
  • Karma: +69/-1
  • Offline Offline
  • Posts: 343
  • Great changes grow bottom up
    • View Profile
    • Scriba.io the Blockchain Scribe
Re: Reference Transaction: Insufficient Balance
« Reply #8 on: September 20, 2016, 08:07:00 pm »

It looks like phasing link transaction may be tricky when, you set a phasing height close to the actual height (edit: perhaps the "distance" does not even matter). I used actualHeight+1 and I now have 3 transactions in the unconfirm pool since hours while the phasing height is in the past and the phasing linked transaction is in the blockchain.

20/09/2016 11:53:01           Ordinary Payment   -43   3   NXT-8MXY-G8AM-375Q-86RRS NXT-ELTE-RFN6-DY7Z-5X63K      -   -
20/09/2016 11:54:01           Ordinary Payment   -43   3   NXT-8MXY-G8AM-375Q-86RRS NXT-ELTE-RFN6-DY7Z-5X63K      -   -
20/09/2016 19:39:02           Ordinary Payment   -52   3   NXT-8GSS-34B7-7B59-ADZFB NXT-SL44-R65Z-HMNZ-7WVJM

I try to understand why.

If the phaseHeight I set was too low, I guess the transactions would have returned an error (I've seen it when I tried) So what can it be ? A rollback, that occurs after the phasing height and then the transaction goes back in the unconfirm pool but can never be included because the phaseHeight is in the past? It looks like they will stay until they expire.

So that means I have to watch for this situation and resend an adapted transaction when I detect it.

I knew transaction could get lost, and may need to be rebroadcasted, but now, it looks like, at least phase transaction, may become invalid and need to be modified before rebroadcasted...   
Logged
Secret Miner <= communicate with style | NotBot <= timestamp digital docs

Riker

  • Core Dev
  • Hero Member
  • *****
  • Karma: +439/-42
  • Offline Offline
  • Posts: 1796
    • View Profile
Re: Reference Transaction: Insufficient Balance
« Reply #9 on: September 21, 2016, 09:21:20 am »

It looks like phasing link transaction may be tricky when, you set a phasing height close to the actual height (edit: perhaps the "distance" does not even matter). I used actualHeight+1 and I now have 3 transactions in the unconfirm pool since hours while the phasing height is in the past and the phasing linked transaction is in the blockchain.

20/09/2016 11:53:01           Ordinary Payment   -43   3   NXT-8MXY-G8AM-375Q-86RRS NXT-ELTE-RFN6-DY7Z-5X63K      -   -
20/09/2016 11:54:01           Ordinary Payment   -43   3   NXT-8MXY-G8AM-375Q-86RRS NXT-ELTE-RFN6-DY7Z-5X63K      -   -
20/09/2016 19:39:02           Ordinary Payment   -52   3   NXT-8GSS-34B7-7B59-ADZFB NXT-SL44-R65Z-HMNZ-7WVJM

I try to understand why.

If the phaseHeight I set was too low, I guess the transactions would have returned an error (I've seen it when I tried) So what can it be ? A rollback, that occurs after the phasing height and then the transaction goes back in the unconfirm pool but can never be included because the phaseHeight is in the past? It looks like they will stay until they expire.

So that means I have to watch for this situation and resend an adapted transaction when I detect it.

I knew transaction could get lost, and may need to be rebroadcasted, but now, it looks like, at least phase transaction, may become invalid and need to be modified before rebroadcasted...

I agree that it has to be something with the finish height set too low. My node no longer accepts these transactions because of "Invalid finish height". I'm not sure how they made it into the unconfirmed pool in the first place. I think they managed to get into the unconfirmed pool just before their finish height was reached but then when a block was forged and the transactions were validated again the finish height has been reached already.
Why do you need to set the finish height close to the current height ?
You can set it to 100 blocks in the future and as soon as the linked transaction is included in a block the phased transaction will execute as well.
Logged
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

websioux

  • Sr. Member
  • ****
  • Karma: +69/-1
  • Offline Offline
  • Posts: 343
  • Great changes grow bottom up
    • View Profile
    • Scriba.io the Blockchain Scribe
Re: Reference Transaction: Insufficient Balance
« Reply #10 on: September 21, 2016, 11:01:22 am »

They are still at the bottom of this page.. https://nxtportal.org/monitor/
anyway..

It is a refund because of mis configured payment (wrong order code, wrong price, too short deadline), so I want to give the money back to the customer such that he can correct and order again. So I prefer he can use the fund as fast as possible and not in 100 blocks (now I have changed it for 10, but I'm not convinced it's not going to happen again).

All of this is related to the fact that I need to be sure that I get credited from the orignal transaction. I could perhaps watch the incoming transaction and rebroadcast when necessary instead of using reference or phase link to guarantee that (except for the too short deadline case). But I first perceived reference transaction and/or phase link transaction as a usefull NXT security service that simplify orders treatment, so I wanted to use it.

In "the end", I'm now using reference transaction if I can (deposit fund available) because it is 1 nxt cheaper and phase link set to 10 blocks ahead otherwise.

Thanks for you help.
Logged
Secret Miner <= communicate with style | NotBot <= timestamp digital docs
 

elective-stereophonic
elective-stereophonic
assembly
assembly