Author [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] Topic: Automatically refunding transactions sent from unregistered accounts?  (Read 434 times)

Offline monsterer


I can refund a transaction from a registered account by looking at the from_account field, which is their account name. An unregistered account has a stealth public key in place of the account name - so, how do I know where to send the refund?
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11958
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #1 on: January 15, 2015, 10:10:16 AM »
every withdraw tx uses a balance_id (address) that holds funds to withdraw from ..
you can just send the funds there and the client should catch up that transaction ..
there's no need to 'identify' the unregistered account .. just refund to the address (balance_id) you received the money from ..
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline monsterer

Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #2 on: January 15, 2015, 10:34:20 AM »
every withdraw tx uses a balance_id (address) that holds funds to withdraw from ..
you can just send the funds there and the client should catch up that transaction ..
there's no need to 'identify' the unregistered account .. just refund to the address (balance_id) you received the money from ..

Are there any docs on what all these fields mean? I had assumed balance_id was like a UTXO and that 'from_account' was the sender.

Take a look at part of this deposit:

Code: [Select]
{
          "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": ""
          }
        }

As you can see there are two balance_id's here, so which one do I pick? AFAIK, I can't send to more than one address in one transaction?
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11958
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #3 on: January 15, 2015, 10:39:34 AM »
every withdraw tx uses a balance_id (address) that holds funds to withdraw from ..
you can just send the funds there and the client should catch up that transaction ..
there's no need to 'identify' the unregistered account .. just refund to the address (balance_id) you received the money from ..

Are there any docs on what all these fields mean? I had assumed balance_id was like a UTXO and that 'from_account' was the sender.

Take a look at part of this deposit:

Code: [Select]
{
          "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": ""
          }
        }

As you can see there are two balance_id's here, so which one do I pick? AFAIK, I can't send to more than one address in one transaction?

balance_id is indeed like a UTXO .. but in bitshares you don't have change-addresses .. so what you do is basically just substract the amount from the balance and leave the rest in the balance_id/address.

in your case the "output" is bigger as your balance_id so that your tx has to combine several "inputs"/utxo

the "output" of the transaction is called "deposit_op_type" and contains a "withdraw_condition" .. which is usually "withdraw_signature_type" .. so you can withdraw with a valid signature ..

as for the "claim_input_data" .. my guess is that this field is required for some specialized withdraw conditions such as the withdraw_by_password .. and contains a parameter of some kind
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline monsterer

Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #4 on: January 15, 2015, 11:22:17 AM »
Here's the whole transaction for reference:

Code: [Select]
[
  "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.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11958
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #5 on: January 15, 2015, 12:01:35 PM »
Here's the whole transaction for reference:

Code: [Select]
[
  "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) ..
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline monsterer

Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #6 on: January 15, 2015, 03:09:16 PM »
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.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11958
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #7 on: January 15, 2015, 05:00:13 PM »
Just send it back to one of the balanceids or addresses in the withdraw operation ... give it a try .. should work nicely
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline toast

Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #8 on: January 15, 2015, 05:17:53 PM »
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.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11958
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #9 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?
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline toast

Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #10 on: January 15, 2015, 05:52:30 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.

Offline monsterer

Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #11 on: January 15, 2015, 06:03:02 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.

Quote
Transfer to the address in the withdraw condition

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

Code: [Select]
"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.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline toast

Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #12 on: January 15, 2015, 06:06:29 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.

Quote
Transfer to the address in the withdraw condition

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

Code: [Select]
"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.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11958
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #13 on: January 15, 2015, 06:07:52 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
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline monsterer

Re: Automatically refunding transactions sent from unregistered accounts?
« Reply #14 on: January 15, 2015, 06:54:46 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.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

 

Google+