bitshares / bitshares-core

BitShares Blockchain node and command-line wallet
https://bitshares.github.io/
Other
1.17k stars 647 forks source link

Buyback mechanisms could be easily extended #387

Open xeroc opened 7 years ago

xeroc commented 7 years ago

Currently, a buyback account can be created using an account_create operation with an extension like this:

     "buyback_options": {
         "asset_to_buy": "1.3.330",
         "asset_to_buy_issuer": "1.2.3563",
         "markets": ["1.3.329"]},

Problems are

Proposal: Allow transfers of CORE to a special account to pay for the order creation fee IFF CORE is not listed in markets.

Discuss!

xeroc commented 7 years ago

On the testnet I get

Skipping buyback processing selling 1.3.329 for  {........}
Account 1.2.3564 'special-account' attempted to pay fee by using asset 1.3.0 'TEST', which is unauthorized due to whitelist / blacklist

Interestingly, this error comes from evaluator.cpp

Which makes me believe that it is not necessarily an issue with markets but rather with whitelisting, but the CORE asset doesn't use a whitelist.

Who can shed some light on this?

//edit: found it. It is indeed caused by allowed_assets which is a list curated by markets See is_authorized_asset.hpp and account_evaluator.cpp.

Not knowing anything about the internal architecture, I would think the easiest way to resolve this is to add CORE to allowed_assets:

obj.allowed_assets->emplace( asset_id_type() );
pmconrad commented 5 years ago

@xeroc I'm not clear about the intent of this issue.

Are buyback accounts used anywhere except for STEALTH? Are there real-life use-cases that we don't support? Would a documentation change "fix" the problem with CORE in allowed_assets?

xeroc commented 5 years ago

Are buyback accounts used anywhere except for STEALTH? Are there real-life use-cases that we don't support? Would a documentation change "fix" the problem with CORE in allowed_assets?

There are real-life use cases we may want to support. A buyback account can be created with the extensions available in account_create_operation. The idea (and implementation) is to have an account where I send profits and the blockchain to use those funds to buy back some defined assets (asset per account creation) from internal markets. That however fails due to the issue described in the OP.

@OpenLedgerApp would be a prime example for this. They want to use profits to buy back OBITS. and instead of doing that manually, they could just send profits to a buyback account for OBITS.

OpenLedgerApp commented 5 years ago

We do it manually for OBITS. We would like to implement a similar mechanism in our proposal - https://github.com/bitshares/bsips/pull/134

We are welcome for discussion.