Skip to content

Commit

Permalink
Pt 160843011 onchain transactions and serializations (#2316)
Browse files Browse the repository at this point in the history
Introduce new fields in off-chain updates  and forced progress while keeping backwards compatibility
  • Loading branch information
velzevur committed Apr 10, 2019
1 parent 593cc78 commit f84b5e6
Show file tree
Hide file tree
Showing 32 changed files with 914 additions and 369 deletions.
19 changes: 10 additions & 9 deletions apps/aechannel/src/aesc_close_mutual_tx.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
check/3,
process/3,
signers/2,
version/0,
version/1,
serialization_template/1,
serialize/1,
deserialize/2,
for_client/1,
valid_at_protocol/2,
initiator_amount_final/1,
responder_amount_final/1
]).
Expand Down Expand Up @@ -142,8 +143,8 @@ serialize(#channel_close_mutual_tx{channel_id = ChannelId,
responder_amount_final = ResponderAmount,
ttl = TTL,
fee = Fee,
nonce = Nonce}) ->
{version(),
nonce = Nonce} = Tx) ->
{version(Tx),
[ {channel_id , ChannelId}
, {from_id , FromId}
, {initiator_amount_final , InitiatorAmount}
Expand Down Expand Up @@ -205,14 +206,14 @@ initiator_amount_final(#channel_close_mutual_tx{initiator_amount_final = Amount
responder_amount_final(#channel_close_mutual_tx{responder_amount_final = Amount}) ->
Amount.

%%%===================================================================
%%% Internal functions
%%%===================================================================

-spec version() -> non_neg_integer().
version() ->
-spec version(tx()) -> non_neg_integer().
version(_) ->
?CHANNEL_CLOSE_MUTUAL_TX_VSN.

-spec valid_at_protocol(aec_hard_forks:protocol_vsn(), tx()) -> boolean().
valid_at_protocol(_, _) ->
true.

%%%===================================================================
%%% Test setters
%%%===================================================================
Expand Down
21 changes: 11 additions & 10 deletions apps/aechannel/src/aesc_close_solo_tx.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
check/3,
process/3,
signers/2,
version/0,
version/1,
serialization_template/1,
serialize/1,
deserialize/2,
for_client/1
for_client/1,
valid_at_protocol/2
]).

%%%===================================================================
Expand Down Expand Up @@ -138,8 +139,8 @@ serialize(#channel_close_solo_tx{channel_id = ChannelId,
poi = PoI,
ttl = TTL,
fee = Fee,
nonce = Nonce}) ->
{version(),
nonce = Nonce} = Tx) ->
{version(Tx),
[ {channel_id, ChannelId}
, {from_id , FromId}
, {payload , Payload}
Expand Down Expand Up @@ -194,11 +195,11 @@ serialization_template(?CHANNEL_CLOSE_SOLO_TX_VSN) ->
, {nonce , int}
].

%%%===================================================================
%%% Internal functions
%%%===================================================================

-spec version() -> non_neg_integer().
version() ->
-spec version(tx()) -> non_neg_integer().
version(_) ->
?CHANNEL_CLOSE_SOLO_TX_VSN.

-spec valid_at_protocol(aec_hard_forks:protocol_vsn(), tx()) -> boolean().
valid_at_protocol(_, _) ->
true.

21 changes: 11 additions & 10 deletions apps/aechannel/src/aesc_create_tx.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
check/3,
process/3,
signers/2,
version/0,
version/1,
serialization_template/1,
serialize/1,
deserialize/2,
for_client/1
for_client/1,
valid_at_protocol/2
]).

%% Getters
Expand Down Expand Up @@ -170,8 +171,8 @@ serialize(#channel_create_tx{initiator_id = InitiatorId,
fee = Fee,
delegate_ids = DelegateIds,
state_hash = StateHash,
nonce = Nonce}) ->
{version(),
nonce = Nonce} = Tx) ->
{version(Tx),
[ {initiator_id , InitiatorId}
, {initiator_amount , InitiatorAmount}
, {responder_id , ResponderId}
Expand Down Expand Up @@ -314,14 +315,14 @@ delegate_ids(#channel_create_tx{delegate_ids = DelegateIds}) ->
delegate_pubkeys(#channel_create_tx{delegate_ids = DelegateIds}) ->
[aeser_id:specialize(D, account) || D <- DelegateIds].

%%%===================================================================
%%% Internal functions
%%%===================================================================

-spec version() -> non_neg_integer().
version() ->
-spec version(tx()) -> non_neg_integer().
version(_) ->
?CHANNEL_CREATE_TX_VSN.

-spec valid_at_protocol(aec_hard_forks:protocol_vsn(), tx()) -> boolean().
valid_at_protocol(_, _) ->
true.

%%%===================================================================
%%% Test setters
%%%===================================================================
Expand Down
21 changes: 11 additions & 10 deletions apps/aechannel/src/aesc_deposit_tx.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
check/3,
process/3,
signers/2,
version/0,
version/1,
serialization_template/1,
serialize/1,
deserialize/2,
for_client/1
for_client/1,
valid_at_protocol/2
]).

% aesc_signable_transaction callbacks
Expand Down Expand Up @@ -171,8 +172,8 @@ serialize(#channel_deposit_tx{channel_id = ChannelId,
fee = Fee,
state_hash = StateHash,
round = Round,
nonce = Nonce}) ->
{version(),
nonce = Nonce} = Tx) ->
{version(Tx),
[ {channel_id , ChannelId}
, {from_id , FromId}
, {amount , Amount}
Expand Down Expand Up @@ -242,14 +243,14 @@ updates(#channel_deposit_tx{from_id = FromId, amount = Amount}) ->
round(#channel_deposit_tx{round = Round}) ->
Round.

%%%===================================================================
%%% Internal functions
%%%===================================================================

-spec version() -> non_neg_integer().
version() ->
-spec version(tx()) -> non_neg_integer().
version(_) ->
?CHANNEL_DEPOSIT_TX_VSN.

-spec valid_at_protocol(aec_hard_forks:protocol_vsn(), tx()) -> boolean().
valid_at_protocol(_, _) ->
true.

%%%===================================================================
%%% Test setters
%%%===================================================================
Expand Down
Loading

0 comments on commit f84b5e6

Please sign in to comment.