Skip to content
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

Hashed Time-Locked Contracts #1370

Merged
merged 56 commits into from Dec 21, 2018
Merged
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c6ca2c8
Initial HTLC commit
jmjatlanta Sep 5, 2018
bab9fb7
Fix compile errors
jmjatlanta Sep 5, 2018
81996c4
Fix tests
jmjatlanta Sep 5, 2018
3afa87e
added signature test
jmjatlanta Sep 7, 2018
6e960ef
Intermediate commit for adding htlc to wallet api
jmjatlanta Sep 14, 2018
f470aa3
Improvements to cli_wallet test
jmjatlanta Sep 16, 2018
b5510ac
Added update_htlc to wallet api
jmjatlanta Sep 17, 2018
40d22aa
Removed debugging code
jmjatlanta Sep 17, 2018
eb1225e
add htlc to switch-case
jmjatlanta Sep 27, 2018
d367c2c
Change method names to match spec
jmjatlanta Oct 12, 2018
6ded688
Boost 1.58 compatibility
jmjatlanta Oct 13, 2018
9a502a3
add get_typename for enum
jmjatlanta Oct 15, 2018
dc82610
Addition of SHA1 and committee parameters
jmjatlanta Oct 15, 2018
49822e1
Refactor committee parameters
jmjatlanta Oct 24, 2018
3ac8323
Test cleanup. Hardfork protection still needed.
jmjatlanta Oct 24, 2018
a30df56
modified name of optional committee parameters
jmjatlanta Oct 26, 2018
b5dae57
beginning of hardfork protection
jmjatlanta Oct 26, 2018
bc48b36
Code cleanup and comments
jmjatlanta Oct 29, 2018
5c5a0d7
Beginning of fee implementation
jmjatlanta Oct 29, 2018
ac29e84
committee fee flexibility and bug fixes
jmjatlanta Oct 30, 2018
50f6584
Calculate fees based on # days
jmjatlanta Oct 30, 2018
e8faf81
Added hardfork protection to proposal_create
jmjatlanta Nov 7, 2018
2c7f7f9
Removed debugging code
jmjatlanta Nov 7, 2018
68982ca
Added base16 to htlc hash for cli wallet
jmjatlanta Dec 11, 2018
44d4134
fix for redeem
jmjatlanta Dec 11, 2018
13926f5
Added details to history for HTLC create and redeem
jmjatlanta Dec 12, 2018
5103f7e
clearer text in account history
jmjatlanta Dec 12, 2018
2e5d74f
Adjust history lines
jmjatlanta Dec 13, 2018
d2dfa69
Modified wallet get_htlc to return pretty format
jmjatlanta Dec 13, 2018
4af8e6c
hash format fix
jmjatlanta Dec 13, 2018
5492797
Add pending info to HTLC in account history
jmjatlanta Dec 13, 2018
742f025
Fix htlc_prepare method signature
jmjatlanta Dec 13, 2018
b5b8dfc
Add virtual op for refund
jmjatlanta Dec 13, 2018
fe24161
Make refund appear in proper account
jmjatlanta Dec 13, 2018
27e2e75
Code cleanup pmconrad suggestions
jmjatlanta Dec 15, 2018
e563899
cleanup, consistent variable naming
jmjatlanta Dec 15, 2018
6239564
More consistent naming
jmjatlanta Dec 15, 2018
e914a37
Switch htlc object from implementation to protocol
jmjatlanta Dec 15, 2018
c808e61
Move committee parameter hardfork validation to visitor
jmjatlanta Dec 15, 2018
fea41d7
htlc_prepare is now htlc_create, plus start of fee testing (wip)
jmjatlanta Dec 17, 2018
e2e571a
1 day and 1kb mins on fees
jmjatlanta Dec 17, 2018
5c7a9e8
still trying to get fees working
jmjatlanta Dec 18, 2018
a2192ec
fix htlc fee tests
jmjatlanta Dec 19, 2018
f7d7f5c
Making fees work with htlc tests
jmjatlanta Dec 19, 2018
96ec5f3
move hash_algoritm enum plus misc
jmjatlanta Dec 19, 2018
0244ff5
Added missing (?) includes
pmconrad Dec 19, 2018
5ffa2a0
Get rid of floating point calculations
pmconrad Dec 19, 2018
145d790
Added hf protection for htlc_operations in proposals
pmconrad Dec 19, 2018
e255f39
Validate that preimage hash length matches algorithm hash length
pmconrad Dec 19, 2018
da6fbef
Refactoring: use a static_variant instead of separate enum + hash vector
pmconrad Dec 19, 2018
793220e
added extend test + smaller misc
jmjatlanta Dec 20, 2018
57248da
handle fee multiplication overflow
jmjatlanta Dec 20, 2018
e8172e9
added messages to asserts
jmjatlanta Dec 20, 2018
2f08968
virtual op for notifications
jmjatlanta Dec 21, 2018
22ea563
More overflow protection + wording changes
jmjatlanta Dec 21, 2018
8e77fff
fix bug in fee calculation
jmjatlanta Dec 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions libraries/chain/protocol/htlc.cpp
Expand Up @@ -28,21 +28,21 @@
namespace graphene { namespace chain {

void htlc_create_operation::validate()const {
FC_ASSERT( fee.amount >= 0 );
FC_ASSERT( amount.amount > 0 );
FC_ASSERT( fee.amount >= 0, "Fee amount should not be zero" );
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
FC_ASSERT( amount.amount > 0, "HTLC amount should not be zero" );
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
}
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved

share_type htlc_create_operation::calculate_fee( const fee_parameters_type& fee_params )const
{
uint64_t days = ( claim_period_seconds + SECONDS_PER_DAY - 1 ) / SECONDS_PER_DAY;
// multiply with overflow check
uint64_t per_day_fee = fee_params.fee_per_day * days;
FC_ASSERT( days == 0 || per_day_fee / fee_params.fee_per_day == days );
FC_ASSERT( days == 0 || per_day_fee / days == fee_params.fee_per_day, "Fee calculation overflow" );
return fee_params.fee + per_day_fee;
}

void htlc_redeem_operation::validate()const {
FC_ASSERT( fee.amount >= 0 );
FC_ASSERT( fee.amount >= 0, "Fee amount should not be zero" );
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
}

share_type htlc_redeem_operation::calculate_fee( const fee_parameters_type& fee_params )const
Expand All @@ -52,14 +52,14 @@ namespace graphene { namespace chain {
}

void htlc_extend_operation::validate()const {
FC_ASSERT( fee.amount >= 0 );
FC_ASSERT( fee.amount >= 0 , "Fee amount should not be zero");
jmjatlanta marked this conversation as resolved.
Show resolved Hide resolved
}

share_type htlc_extend_operation::calculate_fee( const fee_parameters_type& fee_params )const
{
uint32_t days = ( seconds_to_add + SECONDS_PER_DAY - 1 ) / SECONDS_PER_DAY;
uint64_t per_day_fee = fee_params.fee_per_day * days;
FC_ASSERT( days == 0 || per_day_fee / fee_params.fee_per_day == days );
FC_ASSERT( days == 0 || per_day_fee / days == fee_params.fee_per_day, "Fee calculation overflow" );
return fee_params.fee + per_day_fee;
}
} }