-
Notifications
You must be signed in to change notification settings - Fork 86
grammar fixes BSIP 44 (HTLC) #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6dda715
grammar fixes
jmjatlanta 6efbbc2
Added some parameter limits
jmjatlanta 57f21fa
Re-added committee parameters
jmjatlanta bb00710
Updated to match implementation more closely
jmjatlanta cf4206d
punctuation fixes and clarifications
jmjatlanta 9664001
added comments about htlc_hash algos
jmjatlanta 6f72b4b
better spacing in comments
jmjatlanta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,13 +177,11 @@ Bob has now observed the `preimage` Alice used to "unlock" his HTLC, and he will | |
| static const uint8_t space_id = implementation_ids; | ||
| static const uint8_t type_id = impl_htlc_object_type; | ||
|
|
||
| account_id_type depositor; | ||
| account_id_type recipient; | ||
| account_id_type from; | ||
| account_id_type to; | ||
| asset amount; | ||
| fc::time_point_sec expiration; | ||
| asset pending_fee; | ||
| vector<unsigned char> preimage_hash; | ||
| fc::enum_type<uint8_t, hash_algorithm> preimage_hash_algorithm; | ||
| htlc_hash preimage_hash; | ||
| uint16_t preimage_size; | ||
| }; | ||
| ``` | ||
|
|
@@ -199,59 +197,57 @@ Note 3: The initial HTLC expiration can not be more than the maximum amount of t | |
| ### **Prepare** | ||
|
|
||
| ``` | ||
| transaction_obj htlc_prepare(depositor, quantity, symbol, recipient, hash_algorithm, preimage_hash, preimage_length, timeout_threshold, htlc_preparation_fee) | ||
| Validate: HTLC signed by requisite `authority` for `depositor` account | ||
| Validate: `depositor` account has requisite `quantity` of `symbol` asset for the `guarantee` | ||
| transaction_obj htlc_create(from, to, quantity, symbol, hash_algorithm, preimage_hash, preimage_length, timeout_threshold, broadcast) | ||
| Validate: HTLC signed by requisite `authority` for `from` account | ||
| Validate: `from` account has requisite `quantity` of `symbol` asset for the `guarantee` | ||
| Validate: `timeout_threshold` < now() + GRAPHENE_HTLC_MAXIMUM_DURRATION | ||
| Calculate: `required_fee` = GRAPHENE_HTLC_OPERATION_FEE + GRAPHENE_HTLC_DAILY_FEE * count((`timeout_threshold` - now()), days) | ||
| Validate: `depositor` account has requisite `quantity` of BTS for `required_fee` | ||
| Validate: `recipient` account exists | ||
| Validate: `from` account has requisite `quantity` of BTS for `required_fee` | ||
| Validate: `to` account exists | ||
| Validate: `preimage_length` does not exceed GRAPHENE_HTLC_MAXIMUM_PREIMAGE_LENGTH | ||
| Validate: `preimage_hash` well formed | ||
| Update: BTS balance of `depositor` based on `required_fee`) | ||
| contract = new htlc_obj | ||
| Set: `contract.depositor` = `depositor` | ||
| Set: `contract.recipient` = `recipient` | ||
| Set: `contract.from` = `from` | ||
| Set: `contract.to` = `to` | ||
| Set: `contract.hash_algorithm` = `hash_algorithm` | ||
| Set: `contract.preimage_hash` = `preimage_hash` | ||
| Set: `contract.preimage_length` = `preimage_length` | ||
| Set: `contract.timeout_treshold` = `timeout_threshold` | ||
| Transfer: from `depositor` account to `contract.quantity` of `contract.symbol` | ||
| Transfer: remove `contract.quantity` of `contract.symbol` from from` account | ||
|
||
| return results | ||
| ``` | ||
|
|
||
| ### **Redeem** | ||
|
|
||
| ``` | ||
| transaction_obj htlc_redeem(fee_paying_account, id, preimage, htlc_redemption_fee) | ||
| Validate: transaction signed by requisite `authority` for `fee_paying_account` // any account may attempt to redeem | ||
| transaction_obj htlc_redeem(id, issuer, preimage, broadcast) | ||
| Validate: transaction signed by requisite `authority` for `issuer` // NOTE: any account may attempt to redeem | ||
| Get: get_htlc(id) | ||
| Validate: `fee_paying_account` account has requisite `quantity` of BTS for `htlc_redeem_fee` and `htlc_kb_fee` | ||
| Update: balance of `fee_paying_account` based on total fees | ||
| Validate: `issuer` account has requisite `quantity` of BTS for `htlc_redeem_fee` and `htlc_kb_fee` | ||
| // Evaluate: timelock | ||
| if now() < `timeout_threshold` then return error // "timeout exceeded" | ||
| // Evaluate: hashlock | ||
| if length(preimage) != `id.preimage_length` then return error // "preimage length mismatch" | ||
| Calculate: `preimage_hash` = hash(preimage) | ||
| if `preimage_hash` != `id.preimage_hash` then return error // "invalid preimage submitted" | ||
| Update: balance of `id.recipient` add asset `id.symbol` of quantity `id.quantity` | ||
| Update: balance of `id.to` add asset `id.symbol` of quantity `id.quantity` | ||
| Add: transaction to mempool | ||
| Set: `id.preimage_tx_id` = `transaction_id` | ||
| Cleanup: memory allocated to this htlc | ||
| Virtual Operation: Update account history for `depositor` to reflect redemption as by default the above operation will only appear for `redeemer` | ||
| Virtual Operation: Update account history for `from` to reflect redemption as by default the above operation will only appear for `to` | ||
|
|
||
| return: results | ||
| ``` | ||
|
|
||
| ### **Extend Expiry** | ||
|
|
||
| ``` | ||
| transaction_obj htlc_extend_expiry(depositor, id, timeout_threshold, htlc_extention_fee) | ||
| Validate: 'depositor' = get_htlc(id).depositor | ||
| transaction_obj htlc_extend(id, issuer, timeout_threshold, broadcast) | ||
| Validate: 'issuer' = get_htlc(id).from | ||
| Validate: `timeout_threshold` < now() + GRAPHENE_HTLC_MAXIMUM_DURRATION | ||
| Calculate: `required_fee` = GRAPHENE_HTLC_DAILY_FEE * count((`timeout_threshold` - now()), days) | ||
| Validate: `depositor` account has requisite `quantity` of BTS for `required_fee` | ||
| Update: BTS balance of `depositor` based on `required_fee`) | ||
| Validate: `issuer` account has requisite `quantity` of BTS for `required_fee` | ||
| Update: BTS balance of `issuer` based on `required_fee`) | ||
| Set: `contract.timeout_treshold` = `timeout_threshold` | ||
| return results | ||
| ``` | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to define
htlc_hashtype if you mention it here