ArkEcosystem / typescript-client

A simple TypeScript API client for the ARK Blockchain.
MIT License
7 stars 20 forks source link

Transaction never appears on the blockchain. Am I missing something? #27

Closed vladikus10 closed 5 years ago

vladikus10 commented 5 years ago

I'm trying to broadcast a transaction on the mainnet like so:

const ark_client = require('@arkecosystem/client');

async function broadcast(transaction) {

        const client = await ark_client.connect('mainnet', 2);
        const result = await client.resource('transactions').create({ transactions: [transaction] })

        return result;

}

broadcast(JSON.parse(process.argv[2]))
.then(result => console.log(JSON.stringify(result.data, null, 3)))
.catch(e => console.error(e.response.data || e.message));

It is a simple script that I run via the terminal, passing the transaction json object. The thing is, once I do it, I get this response:

{
   "data": {
      "accept": [
         "6f1a6ba828815aadc6e96c9bdd8bf66cf6b10e67de69e4de645ec331dfb71444"
      ],
      "broadcast": [
         "6f1a6ba828815aadc6e96c9bdd8bf66cf6b10e67de69e4de645ec331dfb71444"
      ],
      "excess": [],
      "invalid": []
   },
   "errors": null
}

Which means everything wen't ok! But.. I don't see the transaction on the explorer. It has been already more than an hour since I sent it. Am I missing something here???

zillionn commented 5 years ago

What tx fee you're using?

vladikus10 commented 5 years ago

Hi @zillionn

The fee was 10000000 (0.1 ARK). It is same fee on the receiving transaction of 2 ARK. So I'm trying to send 1.9 ARK, leaving 0.1 for the fee.

But if it is an issue with the fee, shouldn't the blockchain say that there is not enough on the balance to pay the fee or something? I even tried sending 1.8, still the same.

zillionn commented 5 years ago

Try replacing mainnet with your relay IP:PORT or https://explorer.ark.io:8443.

const client = new ark_client('https://explorer.ark.io:8443')
client.setVersion(2)
vladikus10 commented 5 years ago

Nope still same thing with the explorer url:

{
   "data": {
      "accept": [
         "fc9edb29b8015617d0b8244150cde3d5962b13cecaee1861d6b78703bcce142f"
      ],
      "broadcast": [
         "fc9edb29b8015617d0b8244150cde3d5962b13cecaee1861d6b78703bcce142f"
      ],
      "excess": [],
      "invalid": []
   },
   "errors": null
}

And again, nothing changes on the wallet.

The problem with my own relay is that I have no idea how the get the port of it. (ip is obvious)

zillionn commented 5 years ago

The default public API port is 4003.

Can you paste your payload or at least the sender address?

vladikus10 commented 5 years ago

I'm not sure if mine has a different port, but I get connect ECONNREFUSED 127.0.0.1:4003, and ark commander does show that the relay is On and the logs show no errors.

sender address is ATEXZGtxA9i5gT8m6HztfnbLBsGdfvipZ1.

zillionn commented 5 years ago

I'm not sure where the problem is or if it's a bug, you have to send me your payload.

zillionn commented 5 years ago

What if you try to send 1 ARK?

zillionn commented 5 years ago

I've received your tx but for some reason it's not forged by a delegate:

[2019-01-18 13:12:03][DEBUG]   : Transaction fc9edb29b8015617d0b8244150cde3d5962b13cecaee1861d6b78703bcce142f eligible for broadcast - fee of 0.1 Ѧ is greater than minimum fee (0.00789 Ѧ)
[2019-01-18 13:12:03][DEBUG]   : Transaction fc9edb29b8015617d0b8244150cde3d5962b13cecaee1861d6b78703bcce142f eligible to enter pool - fee of 0.1 Ѧ is greater than minimum fee (0.00789 Ѧ)
zillionn commented 5 years ago

I'm not sure if mine has a different port, but I get connect ECONNREFUSED 127.0.0.1:4003, and ark commander does show that the relay is On and the logs show no errors.

API port is not open until your relay is synced.

zillionn commented 5 years ago

I believe I found out where the problem is. Your wallet ATEXZGtxA9i5gT8m6HztfnbLBsGdfvipZ1 is still cold (doesn't have a public key) because your only incoming tx is from Binance. @faustbrian @supaiku0

vladikus10 commented 5 years ago

@zillionn Well that's the whole point. It's a cold storage account, which is created on an offline computer (well not now, but in the future). But just for safety, here is tx (i tried 1 ARk, did not work):

{"expiration":0,"network":0,"timestamp":1884947,"type":0,"version":1,"amount":100000000,"fee":10000000,"asset":{"signature":{},"votes":[],"delegate":{},"multisignature":{"min":0,"lifetime":0,"keysgroup":[]}},"id":"b75bb7522a9e0a3486f2be6b3682915f836114dafb179408c370d11f756b8671","recipientId":"ATtYCbq1MdNYHEE7zA4YZ5K8DguXRVzaz2","senderPublicKey":"02bd76db59c27450900c4432f63863a7e7030d2b33b1bc622b47da106a8ee3e118","signature":"30440220318b4af5338aa010b455149d54ec54c4b6ede668bd54174e4f8ba5f6637beb32022066a458e902cd5311d31dd5859277c171508f1463756dadb751530f9d67b63355","vendorField":"Return tx"}
zillionn commented 5 years ago

It's not you, It looks like a bug in the core.

zillionn commented 5 years ago

OK, it's probably your timestamp 1884947, it's too old/expired. It is related to this issue https://github.com/ArkEcosystem/core/issues/1993

vladikus10 commented 5 years ago

Mhm I see, thanks for the information.

vladikus10 commented 5 years ago

BTW @zillionn , what is the format of the timestamp? It's not a unix timestamp (not in ms or seconds). So what does 1884947 exactly mean?

j-a-m-l commented 5 years ago

@vladikus10 it starts from to the genesis block.

vladikus10 commented 5 years ago

Mhm, tried adding 1000/10000/100000 to the timestamp, did not help.

faustbrian commented 5 years ago

How are you signing transactions? If you use any of the Crypto SDKs the timestamp will be correct if you use the correct network.

vladikus10 commented 5 years ago

I'm using the Java SDK. I see.

One thing I did noticed: by default, it creates a 0 version transaction which is not accepted, so I had to manually set it to 1. Is this normal?

faustbrian commented 5 years ago

The Java SDK or JavaScript SDK?

vladikus10 commented 5 years ago

Java (I'm using Javascript SDK to only broadcast, don't ask why)

faustbrian commented 5 years ago

Could you open an issue in the Java Crypto SDK repository and post the JSON dump of a transaction you signed with it and the code you used to do so?

vladikus10 commented 5 years ago

Okey, I'll do it a bit later, just tried the Javascript SDK transaction and it worked just fine.

I did notice that the JS transaction had less fields (no expiration, network, version and asset was undefined if you compare to the object I commented here before).

faustbrian commented 5 years ago

We have a few exchanges that use the Java Crypto SDK and they have no issues so will need to see the code that generates the transaction.

vladikus10 commented 5 years ago

Ok, I'll open an issue in a moment.