Automatically refunding transactions sent from unregistered accounts?

Started by monsterer, January 15, 2015, 08:40:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xeroc


monsterer

Quote from: xeroc on January 16, 2015, 08:14:35 AM
I noticed that the transaction history does not show transactions that are send to an address directly instead of a TITAN address ... not sure if this is fixed.
You could check this by comparing your "balance" before and after your "refund"

Oh, right you are! Thank you! Yes, ok that's great - so this is working, but its just not shown in the client. I guess this is a bug to be fixed in the client?
My opinions do not represent those of metaexchange unless explicitly stated.
[url="https://metaexchange.info"]https://metaexchange.info[/url] | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

xeroc

I noticed that the transaction history does not show transactions that are send to an address directly instead of a TITAN address ... not sure if this is fixed.
You could check this by comparing your "balance" before and after your "refund"

monsterer

toast, I don't suppose you have a code reference for how you do sharedrops this way? I'm having trouble getting it to work - the funds are sent ok, but never arrive in the recipient's wallet.

psudocode:

BitsharesTransaction t = m_bitshares.BlockchainGetTransaction(depositId);

// get the sender's address from the balance id, from the first op of type withdraw_op_type
BitsharesOperation op = t.trx.operations.First(o => o.type == BitsharesTransactionOp.withdraw_op_type);

BitsharesBalanceRecord balance = m_bitshares.GetBalance(op.data.balance_id);
string senderAddress = balance.condition.data.owner;

response = m_bitshares.WalletTransferToAddress(amount, m_asset.symbol, m_bitsharesAccount, senderAddress, memo);
My opinions do not represent those of metaexchange unless explicitly stated.
[url="https://metaexchange.info"]https://metaexchange.info[/url] | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

monsterer

Quote from: toast on January 15, 2015, 06:06:29 PM
Do you want to refund the exact amount to each input? I'd just pick one arbitrarily since you know they have access to both, like how we credited AGS.

No, all I want is for the transaction to be fully refunded to the sender account - looks like I can do this now, great, thanks! :)
My opinions do not represent those of metaexchange unless explicitly stated.
[url="https://metaexchange.info"]https://metaexchange.info[/url] | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

xeroc

Quote from: toast on January 15, 2015, 05:52:30 PM
Quote from: xeroc on January 15, 2015, 05:35:12 PM
Oh ... so the balanceids is sth. else ... how is the balance id derived? Would sending funds to the balance id also work?

Balance ID is a hash of the withdraw condition. If you sent to it, it would be unrecoverable. Maybe we ought to check that there's not a balance ID equal to the "address" you are sending to to prevent it.
Learnd sth ... thx for the insights

toast

Quote from: monsterer on January 15, 2015, 06:03:02 PM
Quote from: toast on January 15, 2015, 05:17:53 PM
Get the balance record from the balance id:  get_balance BTS6UCvWSmZAsSmhp5E4JRrTLqirBFu7Lfng

But there are multiple balance id's per transaction? In my case I have two of them.

QuoteTransfer to the address in the withdraw condition

Is this not the same as the owner field I have inside the main transaction?

"condition": {
              "asset_id": 0,
              "slate_id": 0,
              "type": "withdraw_signature_type",
              "data": {
                "owner": "BTS82mTkM4nZLBUs7FZBux3zDV4TvdsUcdYR",
                "memo": {
                  "one_time_key": "BTS7P2Ped3mpLeQfuiH8HE9Smoy6cHom1YNNzEqgDg5EmPFPLMDrn",
                  "encrypted_memo_data": "bd8f6702454b0e04284fedcbaf7e4859603a2df1c32f83909ac88e95fc5d13ffb1d71b2f92cec504ef3599c76bd1a7f59e13a535dbed9f96489c906ef131fec3"
                }
              }
            }


?

If there are multiple balances that just means someone merged two inputs. Do you want to refund the exact amount to each input? I'd just pick one arbitrarily since you know they have access to both, like how we credited AGS.

The owner shown in the the raw transaction is in the DEPOSITED balance - you wouldn't be refunding anything but just sending it to yourself.
Do not use this post as information for making any important decisions. The only agreements I ever make are informal and non-binding. Take the same precautions as when dealing with a compromised account, scammer, sockpuppet, etc.

monsterer

Quote from: toast on January 15, 2015, 05:17:53 PM
Get the balance record from the balance id:  get_balance BTS6UCvWSmZAsSmhp5E4JRrTLqirBFu7Lfng

But there are multiple balance id's per transaction? In my case I have two of them.

QuoteTransfer to the address in the withdraw condition

Is this not the same as the owner field I have inside the main transaction?

"condition": {
              "asset_id": 0,
              "slate_id": 0,
              "type": "withdraw_signature_type",
              "data": {
                "owner": "BTS82mTkM4nZLBUs7FZBux3zDV4TvdsUcdYR",
                "memo": {
                  "one_time_key": "BTS7P2Ped3mpLeQfuiH8HE9Smoy6cHom1YNNzEqgDg5EmPFPLMDrn",
                  "encrypted_memo_data": "bd8f6702454b0e04284fedcbaf7e4859603a2df1c32f83909ac88e95fc5d13ffb1d71b2f92cec504ef3599c76bd1a7f59e13a535dbed9f96489c906ef131fec3"
                }
              }
            }


?
My opinions do not represent those of metaexchange unless explicitly stated.
[url="https://metaexchange.info"]https://metaexchange.info[/url] | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

toast

Quote from: xeroc on January 15, 2015, 05:35:12 PM
Oh ... so the balanceids is sth. else ... how is the balance id derived? Would sending funds to the balance id also work?

Balance ID is a hash of the withdraw condition. If you sent to it, it would be unrecoverable. Maybe we ought to check that there's not a balance ID equal to the "address" you are sending to to prevent it.
Do not use this post as information for making any important decisions. The only agreements I ever make are informal and non-binding. Take the same precautions as when dealing with a compromised account, scammer, sockpuppet, etc.

xeroc

Oh ... so the balanceids is sth. else ... how is the balance id derived? Would sending funds to the balance id also work?

toast

Get the balance record from the balance id:  get_balance BTS6UCvWSmZAsSmhp5E4JRrTLqirBFu7Lfng
{
  "condition": {
    "asset_id": 0,
    "slate_id": 0,
    "type": "withdraw_signature_type",
    "data": {
      "owner": "BTSKrYCvm4RcLNqekPiTXHzcrVkxejwAdhfL",
      "memo": null
    }
  },
  "balance": 0,
  "restricted_owner": null,
  "snapshot_info": null,
  "deposit_date": "2015-01-13T08:42:00",
  "last_update": "2015-01-14T08:46:30"
}


Transfer to the address in the withdraw condition

wallet_transfer_to_address blah blah blah BTSKrYCvm4RcLNqekPiTXHzcrVkxejwAdhfL
Do not use this post as information for making any important decisions. The only agreements I ever make are informal and non-binding. Take the same precautions as when dealing with a compromised account, scammer, sockpuppet, etc.

xeroc

Just send it back to one of the balanceids or addresses in the withdraw operation ... give it a try .. should work nicely

monsterer

Thanks for the detail.

I'm still not sure if any of that helps me to figure out how to refund a deposit from an unregistered account in a single transaction, though?
My opinions do not represent those of metaexchange unless explicitly stated.
[url="https://metaexchange.info"]https://metaexchange.info[/url] | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

xeroc

Quote from: monsterer on January 15, 2015, 11:22:17 AM
Here's the whole transaction for reference:

[
  "d888ac6e13fe60d9cdf74c5752b8a4a3f827f4a2",{
    "trx": {
      "expiration": "2015-01-14T09:46:35",
      "delegate_slate_id": null,
      "operations": [{
          "type": "deposit_op_type",
          "data": {
            "amount": 10000,
            "condition": {
              "asset_id": 0,
              "slate_id": 0,
              "type": "withdraw_signature_type",
              "data": {
                "owner": "BTS82mTkM4nZLBUs7FZBux3zDV4TvdsUcdYR",
                "memo": {
                  "one_time_key": "BTS7P2Ped3mpLeQfuiH8HE9Smoy6cHom1YNNzEqgDg5EmPFPLMDrn",
                  "encrypted_memo_data": "bd8f6702454b0e04284fedcbaf7e4859603a2df1c32f83909ac88e95fc5d13ffb1d71b2f92cec504ef3599c76bd1a7f59e13a535dbed9f96489c906ef131fec3"
                }
              }
            }
          }
        },{
          "type": "withdraw_op_type",
          "data": {
            "balance_id": "BTS6UCvWSmZAsSmhp5E4JRrTLqirBFu7Lfng",
            "amount": 10000,
            "claim_input_data": ""
          }
        },{
          "type": "withdraw_op_type",
          "data": {
            "balance_id": "BTSASw7dDN1u3VaSNw5SNYk1WNN9uKBWZoDU",
            "amount": 10000,
            "claim_input_data": ""
          }
        }
      ],
      "signatures": [
        "1f15c6e8076429d5c6a26eb314a2fa0aba1a0650f9af592abd52b25c9377383b4210f01c8c0c18ce1029d311822817dfcea9ceff1fee05f4ad31a5d62bdda6198a",
        "1f6868afae9b4f8d4d7566ec95d71760e695fdd8d232bf0ca3c12b2c764504ec35152a9df4cba00afe46089141bcf5064d28aac6aaf5e36ec41b90f606b0fe83bf"
      ]
    },
    "current_op_index": 3,
    "signed_keys": [],
    "validation_error": null,
    "provided_deposits": [[
        "BTSKdc8euepN6bZ32K5sdvvQQA7GD3udToN7",{
          "amount": 10000,
          "asset_id": 0
        }
      ]
    ],
    "deposits": [[
        0,{
          "amount": 10000,
          "asset_id": 0
        }
      ]
    ],
    "withdraws": [[
        0,{
          "amount": 20000,
          "asset_id": 0
        }
      ]
    ],
    "yield": [],
    "deltas": [[
        0,{
          "amount": 10000,
          "asset_id": 0
        }
      ],[
        1,{
          "amount": -10000,
          "asset_id": 0
        }
      ],[
        2,{
          "amount": -10000,
          "asset_id": 0
        }
      ]
    ],
    "required_fees": {
      "amount": 0,
      "asset_id": 0
    },
    "alt_fees_paid": {
      "amount": 0,
      "asset_id": 0
    },
    "balance": [[
        0,
        10000
      ]
    ],
    "net_delegate_votes": [],
    "chain_location": {
      "block_num": 1520903,
      "trx_num": 0
    }
  }
]


As you can see, balance_id only occurs in the operations array and there are two of them.

deposit_op_type contains a single owner field, is that what you are talking about?


The owner is the receiver (at least one address that was derived from the registered account name) .. if you were the receiver you could figure out if that was your address (read: if you could derive the private key for it) by using the date in the memo (the "one_time_key" - which is a public key).
So: owner -> receiver of the funds
you can also see this as the owner is in the "deposit_op_type" operation and the withdraw condition says "withdraw_signature_type" .. so .. however holds the private key to "the owner" literally owns the shares/coins/assets

The "withdraw_op_type" operations are used to address the "inputs" of the transaction .. those are the operations that have to be "signed" (see signatures - there are two of them) ..
those balance_ids hold transactions that can be redeemed using signatures (so have been sent there with transactions with conditions "withdraw_signature_type")

To test this:
Just take one of your outgoing transactions .. figure out the balance_id and send some funds to that address using wallet_transfer_asset_to_address (or so) ..

monsterer

Here's the whole transaction for reference:

[
  "d888ac6e13fe60d9cdf74c5752b8a4a3f827f4a2",{
    "trx": {
      "expiration": "2015-01-14T09:46:35",
      "delegate_slate_id": null,
      "operations": [{
          "type": "deposit_op_type",
          "data": {
            "amount": 10000,
            "condition": {
              "asset_id": 0,
              "slate_id": 0,
              "type": "withdraw_signature_type",
              "data": {
                "owner": "BTS82mTkM4nZLBUs7FZBux3zDV4TvdsUcdYR",
                "memo": {
                  "one_time_key": "BTS7P2Ped3mpLeQfuiH8HE9Smoy6cHom1YNNzEqgDg5EmPFPLMDrn",
                  "encrypted_memo_data": "bd8f6702454b0e04284fedcbaf7e4859603a2df1c32f83909ac88e95fc5d13ffb1d71b2f92cec504ef3599c76bd1a7f59e13a535dbed9f96489c906ef131fec3"
                }
              }
            }
          }
        },{
          "type": "withdraw_op_type",
          "data": {
            "balance_id": "BTS6UCvWSmZAsSmhp5E4JRrTLqirBFu7Lfng",
            "amount": 10000,
            "claim_input_data": ""
          }
        },{
          "type": "withdraw_op_type",
          "data": {
            "balance_id": "BTSASw7dDN1u3VaSNw5SNYk1WNN9uKBWZoDU",
            "amount": 10000,
            "claim_input_data": ""
          }
        }
      ],
      "signatures": [
        "1f15c6e8076429d5c6a26eb314a2fa0aba1a0650f9af592abd52b25c9377383b4210f01c8c0c18ce1029d311822817dfcea9ceff1fee05f4ad31a5d62bdda6198a",
        "1f6868afae9b4f8d4d7566ec95d71760e695fdd8d232bf0ca3c12b2c764504ec35152a9df4cba00afe46089141bcf5064d28aac6aaf5e36ec41b90f606b0fe83bf"
      ]
    },
    "current_op_index": 3,
    "signed_keys": [],
    "validation_error": null,
    "provided_deposits": [[
        "BTSKdc8euepN6bZ32K5sdvvQQA7GD3udToN7",{
          "amount": 10000,
          "asset_id": 0
        }
      ]
    ],
    "deposits": [[
        0,{
          "amount": 10000,
          "asset_id": 0
        }
      ]
    ],
    "withdraws": [[
        0,{
          "amount": 20000,
          "asset_id": 0
        }
      ]
    ],
    "yield": [],
    "deltas": [[
        0,{
          "amount": 10000,
          "asset_id": 0
        }
      ],[
        1,{
          "amount": -10000,
          "asset_id": 0
        }
      ],[
        2,{
          "amount": -10000,
          "asset_id": 0
        }
      ]
    ],
    "required_fees": {
      "amount": 0,
      "asset_id": 0
    },
    "alt_fees_paid": {
      "amount": 0,
      "asset_id": 0
    },
    "balance": [[
        0,
        10000
      ]
    ],
    "net_delegate_votes": [],
    "chain_location": {
      "block_num": 1520903,
      "trx_num": 0
    }
  }
]


As you can see, balance_id only occurs in the operations array and there are two of them.

deposit_op_type contains a single owner field, is that what you are talking about?
My opinions do not represent those of metaexchange unless explicitly stated.
[url="https://metaexchange.info"]https://metaexchange.info[/url] | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads