hive-keychain/hive-keychain-extension

SBD still showing in return from Hive Keychain after a single payment

brianoflondon opened this issue · 7 comments

This is the answer I get after a single transaction from Keychain paying one amount of HBD:

{
  "success": true,
  "error": null,
  "result": {
    "id": "905ba395d3a9976baa4e0912b4af7894b6f3b118",
    "block_num": 52351529,
    "trx_num": 15,
    "expired": false,
    "ref_block_num": 53783,
    "ref_block_prefix": 3775659032,
    "expiration": "2021-03-22T07:18:45",
    "operations": [
      [
        "transfer",
        {
          "from": "pod2hive",
          "to": "flyingboy",
          "amount": "0.004 SBD",
          "memo": "#FfiephvLrQSU2KXtjCENJdvVtx31YGVRsUbeeShsVF6eiesAjZVmER5aWMqobUo8sJPfoSkiwb9QMvgnqz7TjpLmUTbhXyzVGub5Be2yefS4fyeQTCFN4EDUVTvxP5vLU"
        }
      ]
    ],
    "extensions": [],
    "signatures": [
      "1f56e15f5571f8b6d390209bea19226d22a9529dd76cb276b36d2a903ac561100752bbb0e3bb430117169f3c51c4881a8777fcd46a0d2d0c0404e036d8c516167e"
    ]
  },
  "data": {
    "request_id": 4,
    "type": "transfer",
    "username": "pod2hive",
    "to": "flyingboy",
    "amount": "0.004",
    "memo": "#goat - @v4vapp",
    "enforce": true,
    "currency": "HBD"
  },
  "message": "Successfully transfered 0.004 HBD from @pod2hive to @flyingboy.",
  "request_id": 4,
  "returnTo": "producer.dashboard"
}

The amount in the transfer is listed in SBD.

I only notice this because I'm now doing multiple payments in a single request (which works) and that gives back the following result in the relevant part:

{
  "success": true,
  "error": null,
  "result": {
    "id": "d397189829a21921fcaaa11247ef1b968dc8fd21",
    "block_num": 52351318,
    "trx_num": 0,
    "expired": false,
    "ref_block_num": 53572,
    "ref_block_prefix": 2736223231,
    "expiration": "2021-03-22T07:08:09",
    "operations": [
      [
        "transfer",
        {
          "from": "pod2hive",
          "to": "brianoflondon",
          "amount": "0.170 HBD",
          "memo": "#FfiephvLrQSU2KXtjCENJdvVtx31YGVRsUbeeShsVF6eieLSmUBvmbbnhVUsRfdPm8zKonJtSeV1GKqVr29DM1F6PhrHxFmyL9udHpzQ9kXqjFArXE95PpCqBL2gFrsVW"
        }
      ],

Hmm, are you sure the issue doesn't come from the dApp itself? Was this during your test or on a specific dApp?
Keychain doesn't change the broadcast content

I'm writing the dApp right now and I've never typed SBD into anything.

I'm generating a pay button in python and when that is pressed it tells Keychain to ask the user to make a transfer, that block of json is the answer I get back from Keychain and pass back into my Python back end. It's a complete mystery where SBD comes in but I've handled it.... inelegantly :-)

image

So, just to make sure, if you check the broadcast showing on the extension popup, it shows SBD? Or only in the result?

I can't remember what the UI interface said but I captured the response direct from the javascript and I have that in my debugger right now. The version on the blockchain is HBD, it only appears in the response I got back from the call to keychain.

If it helps this is the javascript I've written which is called when the button is pressed. The destination and amounts are passed in from Python via a hideous templating system.

function hivePay(account, payTo, token, amt, returnTo='podcaster.dashboard'){
    const keychain = window.hive_keychain;
    keychain.requestHandshake(function() {
        console.log("Handshake received!");
    });
    let memo = document.querySelector("input#donationMessage").value;
    let priv = document.querySelector("input#privateMemo").checked;
    if (priv) {
        memo = "#" + memo
    }
    memo += " - @v4vapp";
    console.log(memo)
    // new Audio(karmaSound).play();
    token = token.toUpperCase();
    amt = round(amt, 3);
    console.log("Account = "+ account);
    console.log("payTo = " + payTo);
    console.log("ReturnTo = " + returnTo);
    console.log("token = " + token); // Token name must be all uppercase
    console.log("amt = " + amt);
    keychain.requestTransfer(
        account = account,
        to = payTo,
        amount = amt,
        memo = memo,
        token = token,
        response => {
            console.log(response);
            if (!response.success) { return; }
            response['returnTo'] = returnTo;
            console.log(response);
            axios.post("/podcaster/payment_made", response).then((res) =>{
                console.log(res)
                let paymentSuccess = res.data;
                sessionStorage.setItem("paymentSuccess", JSON.stringify(paymentSuccess));
                window.location.href = `${paymentSuccess.loadPage}`;
            }).catch((err) => {
                console.log(err);
            });
        }, enforce = true);
    };

Doesn't seem to be coming from your code.
I see it correctly shows HBD in hiveblocks, so I m assuming that the transaction was sent correctly :

https://hiveblocks.com/tx/d397189829a21921fcaaa11247ef1b968dc8fd21

And the result is returned as-is from the blockchain. Might be an error with an RPC node.
Pretty sure it's not a Keychain issue, I ll close for now, feel free to reopen if you find hints that it is.

OK I'll live with my if statement for now!

Sorry about that, you were right and I dismissed the issue too quickly. My bad