|
1 | | - BSIP: 0040 |
| 1 | + BSIP: 1041 |
2 | 2 | Title: Escrow Feature |
3 | 3 | Authors: taconator |
4 | 4 | Status: Draft |
@@ -235,8 +235,76 @@ This concept improves on Concept B yet has the following weaknesses: |
235 | 235 | - If an escrow agent is invited, only a single report is required of the escrow agent by the blockchain for the agent receive the escrow fee. |
236 | 236 |
|
237 | 237 | #### Technical Approach |
| 238 | + |
238 | 239 | TBD |
239 | 240 |
|
| 241 | +# Technical Implementation |
| 242 | + |
| 243 | +Note: Any code below should be considered pseudo-code. |
| 244 | + |
| 245 | +The in-memory object for an escrow contract contains: |
| 246 | +``` |
| 247 | +struct escrow_object { |
| 248 | + uint32_t escrow_id; // an ID suitable for sharing |
| 249 | + account_id_type from; // where the asset will be taken from |
| 250 | + account_id_type to; // where the asset will go |
| 251 | + account_id_type agent; // who is the escrow agent |
| 252 | + asset amount; // the asset and amount |
| 253 | + fc::time_point_sec ratification_deadline; // The contract should be agreed upon before this point in time. |
| 254 | + fc::time_point_sec escrow_expiration; // The movement of the asset should take place at this point in time. |
| 255 | + asset pending_fee; // the fee charged for the transaction |
| 256 | + bool to_approved = false; // if the contract was approved by the account ``to`` |
| 257 | + bool agent_approved = false; // if the contract was approved by the escrow agent |
| 258 | + bool disputed = false; // if the contract is being disputed |
| 259 | +}; |
| 260 | +``` |
| 261 | + |
| 262 | +Create a new escrow contract |
| 263 | +``` |
| 264 | +void_result escrow_transfer(const escrow_transfer_operation& o) |
| 265 | +{ |
| 266 | + Verify: ratification_deadline > head_block_time |
| 267 | + Verify: escrow_expiration > head_block_time |
| 268 | + Verify: ``from`` has enough BTS to cover fees |
| 269 | +} |
| 270 | +``` |
| 271 | + |
| 272 | +Approve or reject an escrow contract |
| 273 | +``` |
| 274 | +void_result escrow_approve(const escrow_approve_operation& o) |
| 275 | +{ |
| 276 | + Verify: Not attempting to change ``to`` |
| 277 | + Verify: Not attempting to change ``agent`` |
| 278 | + Verify: ratification_deadline > head_block_time |
| 279 | +} |
| 280 | +``` |
| 281 | + |
| 282 | +Open a dispute on an escrow contract |
| 283 | +``` |
| 284 | +void_result escrow_dispute(const escrow_dispute_operation& o) |
| 285 | +{ |
| 286 | + Verify: contract has been approved by ``to`` and ``agent`` |
| 287 | + Verify: contract is not already in dispute |
| 288 | + Verify: Not attempting to change ``to`` |
| 289 | + Verify: Not attempting to change ``agent`` |
| 290 | +} |
| 291 | +``` |
| 292 | + |
| 293 | +Release an escrow contract |
| 294 | +``` |
| 295 | +void_result escrow_release(const escrow_release_operation& o) |
| 296 | +{ |
| 297 | + Verify: Not attempting to change the asset nor the amount |
| 298 | + Verify: Not attempting to change ``to`` |
| 299 | + Verify: Not attempting to change ``agent`` |
| 300 | + Verify: Funds must only be released to ``to`` or ``from`` |
| 301 | + Verify: Contract must have been approved |
| 302 | + If ( contract is in dispute ) Then only ``agent`` can release funds |
| 303 | + If ( contract is not in dispute ) Then only ``to`` or ``from`` can release funds |
| 304 | + If ( contract is not in dispute ) Then the funds can be released to the opposite party (from->to) or (to->from) |
| 305 | +} |
| 306 | +``` |
| 307 | + |
240 | 308 |
|
241 | 309 | # Discussion |
242 | 310 | ## <a name="responsible-escrow"></a>Responsible Escrow Behavior |
|
0 commit comments