jl777 / SuperNET

57 stars 222 forks source link

`aliceclaim` value not set in values array #920

Open lukechilds opened 6 years ago

lukechilds commented 6 years ago

In https://github.com/jl777/SuperNET/issues/764 you said this is the meaning of the values array:

static char *txnames[] = { "alicespend", "bobspend", "bobpayment", "alicepayment", "bobdeposit", "otherfee", "myfee", "bobrefund", "bobreclaim", "alicereclaim", "aliceclaim" };

However I have a trade with aliceclaim and the aliceclaim value is not set in the array:

{
  "uuid": "00b9fbebeab1b50b200f1fe631eb355bb03ff7d3d71ea6b94ccb18b984f3b3c4",
  "expiration": 1530117529,
  "tradeid": 2852472561,
  "requestid": 3912469824,
  "quoteid": 2093347877,
  "iambob": 0,
  "Bgui": "",
  "Agui": "hyperdex",
  "gui": "hyperdex",
  "bob": "CHIPS",
  "srcamount": 0.78639071,
  "bobtxfee": 0.0001,
  "alice": "KMD",
  "destamount": 0.10009,
  "alicetxfee": 0.00001,
  "aliceid": "15837931641091850241",
  "result": "success",
  "status": "finished",
  "finishtime": 1530536664,
  "bobdeposit": "8509fb343cc41c1d27abd288f0901e3fa34e69b5a381fa80ad40cbed16fe1857",
  "alicepayment": "d29ba65bf9bd356434c1eadf6b0d54a4a9f09f73f5098d2eb4ac097c456f4366",
  "bobpayment": "0000000000000000000000000000000000000000000000000000000000000000",
  "paymentspent": "0000000000000000000000000000000000000000000000000000000000000000",
  "Apaymentspent": "0000000000000000000000000000000000000000000000000000000000000000",
  "depositspent": "d96b723fae4da57c0a821e9375d428a0939d1dec91a19419b17a4d4ed813de4b",
  "method": "tradestatus",
  "values": [
    0,
    0,
    0,
    0.10011,
    0.88488954,
    0,
    0.00012881,
    0,
    0,
    0,
    0
  ],
  "sentflags": [
    "alicepayment",
    "bobdeposit",
    "myfee",
    "aliceclaim"
  ]
}

The last item in values is 0 when it should be 0.88478954.

You can see the aliceclaim tx here: http://chips1.explorer.supernet.org/tx/d96b723fae4da57c0a821e9375d428a0939d1dec91a19419b17a4d4ed813de4b

lukechilds commented 6 years ago

This bug doesn't seem to be consistent, here is another trade that also did an aliceclaim and the aliceclaim value does appear in the values array:

{
  "uuid": "b66ebae5fb25bebb32a68c724e9dd2913a2a30b4a7304eb26b37a2ce0b1b32dd",
  "expiration": 1530105049,
  "tradeid": 131541147,
  "requestid": 1623453337,
  "quoteid": 1904200497,
  "iambob": 0,
  "Bgui": "",
  "Agui": "hyperdex",
  "gui": "hyperdex",
  "bob": "CHIPS",
  "srcamount": 0.10125565,
  "bobtxfee": 0.0001,
  "alice": "KMD",
  "destamount": 0.0134864,
  "alicetxfee": 0.00001,
  "aliceid": "5319286380928565249",
  "result": "success",
  "status": "finished",
  "finishtime": 1530695014,
  "bobdeposit": "09b116ed0123421ba5c4dbc1f44533e381de23e65508c2f5c0b9d7e44fdbc6c8",
  "alicepayment": "54feb40c7a513c7eafee9610dd32e89709b329de37739d36b9cd6e089af5d0de",
  "bobpayment": "0000000000000000000000000000000000000000000000000000000000000000",
  "paymentspent": "0000000000000000000000000000000000000000000000000000000000000000",
  "Apaymentspent": "0000000000000000000000000000000000000000000000000000000000000000",
  "depositspent": "89732f00f62ad3b4f83fb32410d76ed92312addd5249b273d4aac36c8e403b40",
  "method": "tradestatus",
  "values": [
    0,
    0,
    0,
    0.0135064,
    0.1141126,
    0,
    0.00001735,
    0,
    0,
    0,
    0.1140126
  ],
  "sentflags": [
    "alicepayment",
    "bobdeposit",
    "myfee",
    "aliceclaim"
  ]
}
jl777 commented 6 years ago

could it be timing based? it could be that it cant get the value, but then gets to a .finished state. after that it wont do any processing.

So the way to see if it locked onto a null value due to timing, you can delete .finished and do another swapstatus and see if the aliceclaim value is detected

lukechilds commented 6 years ago

Doesn't appear to be that, I just tried kickstarting and it still doesn't display the aliceclaim value.

jl777 commented 6 years ago

very strange. you have the txid for the aliceclaim and it is valid and has the right value?

lukechilds commented 6 years ago

Yeah, linked in the original post ☝️

jl777 commented 6 years ago

I can add some error checking to detect such cases and try to get the value, but if it isnt getting the value now, not sure if retry will work...

in this edge case could you approximate by using the bobdeposit value for aliceclaim?

lukechilds commented 6 years ago

I can for now, that should make the error less noticeable to users.

But still, I feel a little uncomfortable about showing users approximations of what should be absolute values. If there's any possible way you can fix it that would be perfect 👌.

jl777 commented 6 years ago

I can try to reproduce it, given the DB/SWAPS files

lukechilds commented 6 years ago
==> 3912469824-2093347877 <==
{"tradeid":2852472561,"aliceid":"15837931641091850241","src":"CHIPS","srcamount":0.78639071,"dest":"KMD","destamount":0.10009000,"requestid":3912469824,"quoteid":2093347877,"iambob":0,"state":64,"otherstate":0,"expiration":1530117529,"dlocktime":1530117529,"plocktime":0,"Atxfee":1000,"Btxfee":10000,"Agui":"hyperdex","gui":"hyperdex","uuid":"00b9fbebeab1b50b200f1fe631eb355bb03ff7d3d71ea6b94ccb18b984f3b3c4","secretAm":"7b4464af444a06b663a4a82694e3785b07b06d1d","secretAm256":"8076f9dabc4c698da141e76407b5328a14b1ac7d125af6fbd602e8896f59d848","secretBn":"93f3d46a92276873101f375069d8f156c7b3446b","secretBn256":"77af343482113fda94be7853936ac70336e063d19f35f7fc312bc843ad3e0e0d","myprivs0":"298f224d7eadb608eda15034c775badd81eed8f570760f2b9d5696168e82c67f","myprivs1":"664b9a9c56295cc6e3b0470c120be7a73a0afd7e030f559e37adc0de6567a182","privAm":"4c232c833934959f72c86e2fde0bc17dbb85e09a83a69e29759bec3ebba49bd1","pubA0":"440ffde1c38d1cf1c721213f4c7ac22dcd5d7dbb04ae381e4f9741d088ee76d2","pubB0":"f1f263aa71c32c3e61b8076514bfc149c5d9d59d6b9cf1006bc13b86260d7809","pubB1":"1e6539d1273e10bb1b956cbfaca94fddfa56954949c4533007f0bb4cfef7fe22","Bdeposit":"8509fb343cc41c1d27abd288f0901e3fa34e69b5a381fa80ad40cbed16fe1857","Apayment":"d29ba65bf9bd356434c1eadf6b0d54a4a9f09f73f5098d2eb4ac097c456f4366","myfee":"982ce4e35611039c9cdd6e340057497dc0b1deb1947f3827e58737ed55e74f4a","other33":"0315d9c51c657ab1be4ae9d3ab6e76a619d3bccfe830d5363fa168424c0d044732","dest33":"0330b4191bd253364abe8c19976f196bbcc2f3e66724816ef70e7fe472b5f59d0c"}

==> 3912469824-2093347877.alicepayment <==
{"name":"alicepayment","coin":"KMD","tx":"0100000001182b9182c66a4ebd4fb0e0258c1e92501b11cca7634a9be20906b2a0afa0dbcb000000006a47304402207aec51c7aa8dea95873d4ef74381fa5e49a336fffd17c2df14effd26e01584f9022042eef7e69e0760b0b58779050cd834e74e2e0c53b10930697770e9425736269401210330b4191bd253364abe8c19976f196bbcc2f3e66724816ef70e7fe472b5f59d0cffffffff0278c198000000000017a914029e239e5336cab32739fde9465d2ae09134ff148727b45900000000001976a914a9d2476fa20db74a8a9117f7999614ecb5b0a9d988acb07d335b","txid":"d29ba65bf9bd356434c1eadf6b0d54a4a9f09f73f5098d2eb4ac097c456f4366","Bdeposit":"bJTFQR29UnWjQbyBQ1J5cRRgzEvF2ZRB63","expiration":1530117529,"uuid":"00b9fbebeab1b50b200f1fe631eb355bb03ff7d3d71ea6b94ccb18b984f3b3c4","iambob":0,"bobcoin":"CHIPS","bobDepositEthTx":"0x0000000000000000000000000000000000000000000000000000000000000000","aliceRealSat":"0","bobRealSat":"0","alicecoin":"KMD","lock":0,"amount":0.10011000,"trigger":"8509fb343cc41c1d27abd288f0901e3fa34e69b5a381fa80ad40cbed16fe1857","Apayment":"bCy7VKAuuC4LBUYpXDBDryXNjUekSgVLWc","redeem":"522102795c7e27c6eff2d4dd2654148d71a4e0ffa97b4c12a0699508d7b1966615376221031707bc9280d89ff6370792a7cd822be8d4effa60d2dde2e0f1124120ebb5f19152ae"}

==> 3912469824-2093347877.bobdeposit <==
{"name":"bobdeposit","coin":"CHIPS","tx":"0100000001288642aee5b20fc77f5b497bbde2227bd417d40da310c214fd2e9cf21516e06c000000006a47304402206f44571a75639a6c5d7ff0ff16d23c0a02d513b91f50bc80806e3e0932baa1ce022005930c64d1fd09561fd364e33c190f410cdac387e4ea6fefde9ce4e38f06cd9201210315d9c51c657ab1be4ae9d3ab6e76a619d3bccfe830d5363fa168424c0d044732ffffffff02fa3b46050000000017a9143ec905c4f7f1cef899bf5a5e6d4d9b3e10a8b6c7879bb32300000000001976a9141462c3dd3f936d595c9af55978003b27c250441f88ac99bd335b","txid":"8509fb343cc41c1d27abd288f0901e3fa34e69b5a381fa80ad40cbed16fe1857","Bdeposit":"bJTFQR29UnWjQbyBQ1J5cRRgzEvF2ZRB63","expiration":1530117529,"uuid":"00b9fbebeab1b50b200f1fe631eb355bb03ff7d3d71ea6b94ccb18b984f3b3c4","iambob":0,"bobcoin":"CHIPS","bobDepositEthTx":"0x0000000000000000000000000000000000000000000000000000000000000000","aliceRealSat":"0","bobRealSat":"0","alicecoin":"KMD","lock":0,"amount":0.88488954,"Apayment":"bCy7VKAuuC4LBUYpXDBDryXNjUekSgVLWc","redeem":"630499bd335bb17582012088a9147b4464af444a06b663a4a82694e3785b07b06d1d882102440ffde1c38d1cf1c721213f4c7ac22dcd5d7dbb04ae381e4f9741d088ee76d2ac6782012088a914e229432739347a2a25160d7c2a4cca8043499215882103f1f263aa71c32c3e61b8076514bfc149c5d9d59d6b9cf1006bc13b86260d7809ac68"}

==> 3912469824-2093347877.bobrefund <==
{"name":"bobrefund","coin":"CHIPS","Bdeposit":"bJTFQR29UnWjQbyBQ1J5cRRgzEvF2ZRB63","expiration":1530117529,"uuid":"00b9fbebeab1b50b200f1fe631eb355bb03ff7d3d71ea6b94ccb18b984f3b3c4","iambob":0,"bobcoin":"CHIPS","bobDepositEthTx":"0x0000000000000000000000000000000000000000000000000000000000000000","aliceRealSat":"0","bobRealSat":"0","alicecoin":"KMD","lock":1530117529,"amount":0.88468954,"Apayment":"bCy7VKAuuC4LBUYpXDBDryXNjUekSgVLWc"}

==> 3912469824-2093347877.finished <==
{"uuid":"00b9fbebeab1b50b200f1fe631eb355bb03ff7d3d71ea6b94ccb18b984f3b3c4","expiration":1530117529,"tradeid":2852472561,"requestid":3912469824,"quoteid":2093347877,"iambob":0,"Bgui":"","Agui":"hyperdex","gui":"hyperdex","bob":"CHIPS","srcamount":0.78639071,"bobtxfee":0.00010000,"alice":"KMD","destamount":0.10009000,"alicetxfee":0.00001000,"aliceid":"15837931641091850241","sentflags":["alicepayment", "bobdeposit", "myfee", "aliceclaim"],"values":[0, 0, 0, 0.10011000, 0.88488954, 0, 0.00012881, 0, 0, 0, 0],"result":"success","status":"finished","finishtime":1530776206,"bobdeposit":"8509fb343cc41c1d27abd288f0901e3fa34e69b5a381fa80ad40cbed16fe1857","alicepayment":"d29ba65bf9bd356434c1eadf6b0d54a4a9f09f73f5098d2eb4ac097c456f4366","bobpayment":"0000000000000000000000000000000000000000000000000000000000000000","paymentspent":"0000000000000000000000000000000000000000000000000000000000000000","Apaymentspent":"0000000000000000000000000000000000000000000000000000000000000000","depositspent":"d96b723fae4da57c0a821e9375d428a0939d1dec91a19419b17a4d4ed813de4b","method":"tradestatus","finishtime":1530776206}

==> 3912469824-2093347877.myfee <==
{"name":"myfee","coin":"KMD","tx":"0100000001a047ccf267f496c8fa5688b9c322ddff8477daaa90f74ca471de7b1da2ea2433010000006b483045022100aca572d34b13053ef35585db3ed7190eb223aa8f2d37bd6c249a30da96eaefb602203130636d116a490333e2d5d53a512d51722ccf7a6c30eb648f3c6cd86aa3a51a01210330b4191bd253364abe8c19976f196bbcc2f3e66724816ef70e7fe472b5f59d0cffffffff0251320000000000001976a914ca1e04745e8ca0c60d8c5881531d51bec470743f88acfafe0000000000001976a914a9d2476fa20db74a8a9117f7999614ecb5b0a9d988acaa80335b","txid":"982ce4e35611039c9cdd6e340057497dc0b1deb1947f3827e58737ed55e74f4a","expiration":1530117529,"uuid":"00b9fbebeab1b50b200f1fe631eb355bb03ff7d3d71ea6b94ccb18b984f3b3c4","iambob":0,"bobcoin":"CHIPS","aliceRealSat":"0","bobRealSat":"0","alicecoin":"KMD","lock":0,"amount":0.00012881,"Apayment":"bCy7VKAuuC4LBUYpXDBDryXNjUekSgVLWc"}
lukechilds commented 6 years ago

@jl777 Did you get anywhere with this?

jl777 commented 6 years ago

I get values, but I guess I need to use the exact SPV servers and not native mode?

lukechilds commented 6 years ago

Interesting that it works in native mode.

These are the Electrum servers I used:

{
        coin: 'KMD',
        electrumServers: [
            {
                host: 'electrum1.cipig.net',
                port: 10001,
            },
            {
                host: 'electrum2.cipig.net',
                port: 10001,
            },
        ],
    },
{
        coin: 'CHIPS',
        name: 'Chips',
        rpcport: 57776,
        pubtype: 60,
        p2shtype: 85,
        wiftype: 188,
        txfee: 10000,
        electrumServers: [
            {
                host: 'electrum1.cipig.net',
                port: 10053,
            },
            {
                host: 'electrum2.cipig.net',
                port: 10053,
            },
        ],
    },
jl777 commented 6 years ago

Finally found the problem! internally it was set so aliceclaim was thought to be alicecoin instead of bobcoin, so it failed to get the txid info as it was querying the wrong coin!

pushed fix to dev branch

lukechilds commented 6 years ago

Awesome, thanks James!

I think @artemii235 has set his repo to auto create a PR when you push to dev. So we should be able to get this in HyperDEX pretty soon. Will report back when I've tested.

artemii235 commented 6 years ago

Dev branch was not updated yet, there is a PR waiting for merge. Automatic PR in my fork won't be created until this PR is merged.

artemii235 commented 6 years ago

https://github.com/artemii235/SuperNET/releases/tag/v1.0.311 - PR merged

lukechilds commented 6 years ago

@jl777 Should this retroactively fix previous trades?

If I call swapstatus or kickstart on the swap mentioned in this issue I never get the aliceclaim value populated:

{
  "uuid": "00b9fbebeab1b50b200f1fe631eb355bb03ff7d3d71ea6b94ccb18b984f3b3c4",
  "expiration": 1530117529,
  "tradeid": 2852472561,
  "requestid": 3912469824,
  "quoteid": 2093347877,
  "iambob": 0,
  "Bgui": "",
  "Agui": "hyperdex",
  "gui": "hyperdex",
  "bob": "CHIPS",
  "srcamount": 0.78639071,
  "bobtxfee": 0.0001,
  "alice": "KMD",
  "destamount": 0.10009,
  "alicetxfee": 0.00001,
  "aliceid": "15837931641091850241",
  "sentflags": [
    "bobspend",
    "alicepayment",
    "bobdeposit",
    "myfee",
    "aliceclaim"
  ],
  "values": [
    0,
    0,
    0,
    0.10011,
    0.88488954,
    0,
    0.00012881,
    0,
    0,
    0,
    0
  ],
  "result": "success",
  "status": "finished",
  "finishtime": 1531483660,
  "bobdeposit": "8509fb343cc41c1d27abd288f0901e3fa34e69b5a381fa80ad40cbed16fe1857",
  "alicepayment": "d29ba65bf9bd356434c1eadf6b0d54a4a9f09f73f5098d2eb4ac097c456f4366",
  "bobpayment": "0000000000000000000000000000000000000000000000000000000000000000",
  "paymentspent": "0000000000000000000000000000000000000000000000000000000000000000",
  "Apaymentspent": "4c75699b58b046d67a0ce642d8014e9762706916813b3391b7b9c14ce98a6104",
  "depositspent": "d96b723fae4da57c0a821e9375d428a0939d1dec91a19419b17a4d4ed813de4b",
  "alicedexfee": "982ce4e35611039c9cdd6e340057497dc0b1deb1947f3827e58737ed55e74f4a",
  "method": "tradestatus"
}
jl777 commented 6 years ago

if there is no .finished file, it should reprocess it and if it is fixed, it should work

lukechilds commented 6 years ago

The above output is after a kickstart. That should remove .finished and force a kickstart, right?

If so, it looks like it's not fixed. There's no aliceclaim value, even though the aliceclaim TXID is in depositspent.