This repository has been archived by the owner on Oct 4, 2019. It is now read-only.
forked from steemit/steem
/
steem_operations.hpp
1259 lines (1001 loc) · 49.7 KB
/
steem_operations.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma once
#include <golos/protocol/base.hpp>
#include <golos/protocol/block_header.hpp>
#include <golos/protocol/asset.hpp>
#include <fc/utf8.hpp>
#include <fc/crypto/equihash.hpp>
namespace golos { namespace protocol {
struct account_create_operation : public base_operation {
asset fee;
account_name_type creator;
account_name_type new_account_name;
authority owner;
authority active;
authority posting;
public_key_type memo_key;
string json_metadata;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type>& a) const {
a.insert(creator);
}
};
struct account_create_with_delegation_operation: public base_operation {
asset fee;
asset delegation;
account_name_type creator;
account_name_type new_account_name;
authority owner;
authority active;
authority posting;
public_key_type memo_key;
string json_metadata;
extensions_type extensions;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type>& a) const {
a.insert(creator);
}
};
struct account_update_operation : public base_operation {
account_name_type account;
optional<authority> owner;
optional<authority> active;
optional<authority> posting;
public_key_type memo_key;
string json_metadata;
void validate() const;
void get_required_owner_authorities(flat_set<account_name_type> &a) const {
if (owner) {
a.insert(account);
}
}
void get_required_active_authorities(flat_set<account_name_type> &a) const {
if (!owner) {
a.insert(account);
}
}
};
struct account_metadata_operation : public base_operation {
account_name_type account;
string json_metadata;
void validate() const;
void get_required_posting_authorities(flat_set<account_name_type>& a) const {
a.insert(account);
}
};
struct comment_operation : public base_operation {
account_name_type parent_author;
string parent_permlink;
account_name_type author;
string permlink;
string title;
string body;
string json_metadata;
void validate() const;
void get_required_posting_authorities(flat_set<account_name_type> &a) const {
a.insert(author);
}
};
struct beneficiary_route_type {
beneficiary_route_type() {
}
beneficiary_route_type(const account_name_type &a, const uint16_t &w)
: account(a), weight(w) {
}
account_name_type account;
uint16_t weight;
// For use by std::sort such that the route is sorted first by name (ascending)
bool operator<(const beneficiary_route_type &o) const {
return string_less()(account, o.account);
}
};
struct comment_payout_beneficiaries {
vector <beneficiary_route_type> beneficiaries;
void validate() const;
};
typedef static_variant <
comment_payout_beneficiaries
> comment_options_extension;
typedef flat_set <comment_options_extension> comment_options_extensions_type;
/**
* Authors of posts may not want all of the benefits that come from creating a post. This
* operation allows authors to update properties associated with their post.
*
* The max_accepted_payout may be decreased, but never increased.
* The percent_steem_dollars may be decreased, but never increased
*
*/
struct comment_options_operation : public base_operation {
account_name_type author;
string permlink;
asset max_accepted_payout = asset(1000000000, SBD_SYMBOL); /// SBD value of the maximum payout this post will receive
uint16_t percent_steem_dollars = STEEMIT_100_PERCENT; /// the percent of Golos Dollars to key, unkept amounts will be received as Golos Power
bool allow_votes = true; /// allows a post to receive votes;
bool allow_curation_rewards = true; /// allows voters to recieve curation rewards. Rewards return to reward fund.
comment_options_extensions_type extensions;
void validate() const;
void get_required_posting_authorities(flat_set<account_name_type> &a) const {
a.insert(author);
}
};
struct challenge_authority_operation : public base_operation {
account_name_type challenger;
account_name_type challenged;
bool require_owner = false;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type>& a) const {
a.insert(challenger);
}
};
struct prove_authority_operation : public base_operation {
account_name_type challenged;
bool require_owner = false;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type>& a) const {
if (!require_owner) {
a.insert(challenged);
}
}
void get_required_owner_authorities(flat_set<account_name_type>& a) const {
if (require_owner) {
a.insert(challenged);
}
}
};
struct delete_comment_operation : public base_operation {
account_name_type author;
string permlink;
void validate() const;
void get_required_posting_authorities(flat_set<account_name_type> &a) const {
a.insert(author);
}
};
struct vote_operation : public base_operation {
account_name_type voter;
account_name_type author;
string permlink;
int16_t weight = 0;
void validate() const;
void get_required_posting_authorities(flat_set<account_name_type> &a) const {
a.insert(voter);
}
};
/**
* @ingroup operations
*
* @brief Transfers STEEM from one account to another.
*/
struct transfer_operation : public base_operation {
account_name_type from;
/// Account to transfer asset to
account_name_type to;
/// The amount of asset to transfer from @ref from to @ref to
asset amount;
/// The memo is plain-text, any encryption on the memo is up to
/// a higher level protocol.
string memo;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
if (amount.symbol != VESTS_SYMBOL) {
a.insert(from);
}
}
void get_required_owner_authorities(flat_set<account_name_type> &a) const {
if (amount.symbol == VESTS_SYMBOL) {
a.insert(from);
}
}
};
/**
* The purpose of this operation is to enable someone to send money contingently to
* another individual. The funds leave the *from* account and go into a temporary balance
* where they are held until *from* releases it to *to* or *to* refunds it to *from*.
*
* In the event of a dispute the *agent* can divide the funds between the to/from account.
* Disputes can be raised any time before or on the dispute deadline time, after the escrow
* has been approved by all parties.
*
* This operation only creates a proposed escrow transfer. Both the *agent* and *to* must
* agree to the terms of the arrangement by approving the escrow.
*
* The escrow agent is paid the fee on approval of all parties. It is up to the escrow agent
* to determine the fee.
*
* Escrow transactions are uniquely identified by 'from' and 'escrow_id', the 'escrow_id' is defined
* by the sender.
*/
struct escrow_transfer_operation : public base_operation {
account_name_type from;
account_name_type to;
account_name_type agent;
uint32_t escrow_id = 30;
asset sbd_amount = asset(0, SBD_SYMBOL);
asset steem_amount = asset(0, STEEM_SYMBOL);
asset fee;
time_point_sec ratification_deadline;
time_point_sec escrow_expiration;
string json_meta;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(from);
}
};
/**
* The agent and to accounts must approve an escrow transaction for it to be valid on
* the blockchain. Once a part approves the escrow, the cannot revoke their approval.
* Subsequent escrow approve operations, regardless of the approval, will be rejected.
*/
struct escrow_approve_operation : public base_operation {
account_name_type from;
account_name_type to;
account_name_type agent;
account_name_type who; // Either to or agent
uint32_t escrow_id = 30;
bool approve = true;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(who);
}
};
/**
* If either the sender or receiver of an escrow payment has an issue, they can
* raise it for dispute. Once a payment is in dispute, the agent has authority over
* who gets what.
*/
struct escrow_dispute_operation : public base_operation {
account_name_type from;
account_name_type to;
account_name_type agent;
account_name_type who;
uint32_t escrow_id = 30;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(who);
}
};
/**
* This operation can be used by anyone associated with the escrow transfer to
* release funds if they have permission.
*
* The permission scheme is as follows:
* If there is no dispute and escrow has not expired, either party can release funds to the other.
* If escrow expires and there is no dispute, either party can release funds to either party.
* If there is a dispute regardless of expiration, the agent can release funds to either party
* following whichever agreement was in place between the parties.
*/
struct escrow_release_operation : public base_operation {
account_name_type from;
account_name_type to; ///< the original 'to'
account_name_type agent;
account_name_type who; ///< the account that is attempting to release the funds, determines valid 'receiver'
account_name_type receiver; ///< the account that should receive funds (might be from, might be to)
uint32_t escrow_id = 30;
asset sbd_amount = asset(0, SBD_SYMBOL); ///< the amount of sbd to release
asset steem_amount = asset(0, STEEM_SYMBOL); ///< the amount of steem to release
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(who);
}
};
/**
* This operation converts STEEM into VFS (Vesting Fund Shares) at
* the current exchange rate. With this operation it is possible to
* give another account vesting shares so that faucets can
* pre-fund new accounts with vesting shares.
*/
struct transfer_to_vesting_operation : public base_operation {
account_name_type from;
account_name_type to; ///< if null, then same as from
asset amount; ///< must be STEEM
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(from);
}
};
/**
* At any given point in time an account can be withdrawing from their
* vesting shares. A user may change the number of shares they wish to
* cash out at any time between 0 and their total vesting stake.
*
* After applying this operation, vesting_shares will be withdrawn
* at a rate of vesting_shares/104 per week for two years starting
* one week after this operation is included in the blockchain.
*
* This operation is not valid if the user has no vesting shares.
*/
struct withdraw_vesting_operation : public base_operation {
account_name_type account;
asset vesting_shares;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(account);
}
};
/**
* Allows an account to setup a vesting withdraw but with the additional
* request for the funds to be transferred directly to another account's
* balance rather than the withdrawing account. In addition, those funds
* can be immediately vested again, circumventing the conversion from
* vests to steem and back, guaranteeing they maintain their value.
*/
struct set_withdraw_vesting_route_operation : public base_operation {
account_name_type from_account;
account_name_type to_account;
uint16_t percent = 0;
bool auto_vest = false;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(from_account);
}
};
struct chain_properties_18;
struct chain_properties_19;
/**
* Witnesses must vote on how to set certain chain properties to ensure a smooth
* and well functioning network. Any time @owner is in the active set of witnesses these
* properties will be used to control the blockchain configuration.
*/
struct chain_properties_17 {
/**
* This fee, paid in STEEM, is converted into VESTING SHARES for the new account. Accounts
* without vesting shares cannot earn usage rations and therefore are powerless. This minimum
* fee requires all accounts to have some kind of commitment to the network that includes the
* ability to vote and make transactions.
*/
asset account_creation_fee =
asset(STEEMIT_MIN_ACCOUNT_CREATION_FEE, STEEM_SYMBOL);
/**
* This witnesses vote for the maximum_block_size which is used by the network
* to tune rate limiting and capacity
*/
uint32_t maximum_block_size = STEEMIT_MIN_BLOCK_SIZE_LIMIT * 2;
uint16_t sbd_interest_rate = STEEMIT_DEFAULT_SBD_INTEREST_RATE;
void validate() const;
chain_properties_17& operator=(const chain_properties_17&) = default;
chain_properties_17& operator=(const chain_properties_18& src);
};
/**
* Witnesses must vote on how to set certain chain properties to ensure a smooth
* and well functioning network. Any time @owner is in the active set of witnesses these
* properties will be used to control the blockchain configuration.
*/
struct chain_properties_18: public chain_properties_17 {
/**
* Minimum fee (in GOLOS) payed when create account with delegation
*/
asset create_account_min_golos_fee =
asset(STEEMIT_MIN_ACCOUNT_CREATION_FEE * GOLOS_CREATE_ACCOUNT_WITH_GOLOS_MODIFIER, STEEM_SYMBOL);
/**
* Minimum GP delegation amount when create account with delegation
*
* Note: this minimum is applied only when fee is minimal. If fee is greater,
* then actual delegation can be less (up to 0 if fee part is greater or equal than account_creation_fee)
*/
asset create_account_min_delegation =
asset(STEEMIT_MIN_ACCOUNT_CREATION_FEE *
GOLOS_CREATE_ACCOUNT_WITH_GOLOS_MODIFIER * GOLOS_CREATE_ACCOUNT_DELEGATION_RATIO, STEEM_SYMBOL);
/**
* Minimum time of delegated GP on create account (in seconds)
*/
uint32_t create_account_delegation_time = (GOLOS_CREATE_ACCOUNT_DELEGATION_TIME).to_seconds();
/**
* Minimum delegated GP
*/
asset min_delegation =
asset(STEEMIT_MIN_ACCOUNT_CREATION_FEE * GOLOS_MIN_DELEGATION_MULTIPLIER, STEEM_SYMBOL);
void validate() const;
chain_properties_18& operator=(const chain_properties_17& src) {
account_creation_fee = src.account_creation_fee;
maximum_block_size = src.maximum_block_size;
sbd_interest_rate = src.sbd_interest_rate;
return *this;
}
chain_properties_18& operator=(const chain_properties_18&) = default;
chain_properties_18& operator=(const chain_properties_19& src);
};
struct chain_properties_19: public chain_properties_18 {
/**
* Голосуемый параметр. Штрафное окно голосования
*/
uint32_t auction_window_size = STEEMIT_REVERSE_AUCTION_WINDOW_SECONDS;
void validate() const;
chain_properties_19& operator=(const chain_properties_17& src) {
account_creation_fee = src.account_creation_fee;
maximum_block_size = src.maximum_block_size;
sbd_interest_rate = src.sbd_interest_rate;
return *this;
}
chain_properties_19& operator=(const chain_properties_18& src) {
// 18
create_account_min_golos_fee = src.create_account_min_golos_fee;
create_account_min_delegation = src.create_account_min_delegation;
create_account_delegation_time = src.create_account_delegation_time;
min_delegation = src.min_delegation;
// 17
account_creation_fee = src.account_creation_fee;
maximum_block_size = src.maximum_block_size;
sbd_interest_rate = src.sbd_interest_rate;
return *this;
}
chain_properties_19& operator=(const chain_properties_19&) = default;
};
inline chain_properties_17& chain_properties_17::operator=(const chain_properties_18& src) {
account_creation_fee = src.account_creation_fee;
maximum_block_size = src.maximum_block_size;
sbd_interest_rate = src.sbd_interest_rate;
return *this;
}
inline chain_properties_18& chain_properties_18::operator=(const chain_properties_19& src) {
create_account_min_golos_fee = src.create_account_min_golos_fee;
create_account_min_delegation = src.create_account_min_delegation;
create_account_delegation_time = src.create_account_delegation_time;
min_delegation = src.min_delegation;
return *this;
}
using versioned_chain_properties = fc::static_variant<
chain_properties_17,
chain_properties_18,
chain_properties_19
>;
/**
* Users who wish to become a witness must pay a fee acceptable to
* the current witnesses to apply for the position and allow voting
* to begin.
*
* If the owner isn't a witness they will become a witness. Witnesses
* are charged a fee equal to 1 weeks worth of witness pay which in
* turn is derived from the current share supply. The fee is
* only applied if the owner is not already a witness.
*
* If the block_signing_key is null then the witness is removed from
* contention. The network will pick the top 21 witnesses for
* producing blocks.
*/
struct witness_update_operation : public base_operation {
account_name_type owner;
string url;
public_key_type block_signing_key;
chain_properties_17 props;
asset fee; ///< the fee paid to register a new witness, should be 10x current block production pay
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(owner);
}
};
/**
* Wintesses can change some dynamic votable params to control the blockchain configuration
*/
struct chain_properties_update_operation : public base_operation {
account_name_type owner;
versioned_chain_properties props;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(owner);
}
};
/**
* All accounts with a VFS can vote for or against any witness.
*
* If a proxy is specified then all existing votes are removed.
*/
struct account_witness_vote_operation : public base_operation {
account_name_type account;
account_name_type witness;
bool approve = true;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(account);
}
};
struct account_witness_proxy_operation : public base_operation {
account_name_type account;
account_name_type proxy;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(account);
}
};
/**
* @brief provides a generic way to add higher level protocols on top of witness consensus
* @ingroup operations
*
* There is no validation for this operation other than that required auths are valid
*/
struct custom_operation : public base_operation {
flat_set<account_name_type> required_auths;
uint16_t id = 0;
vector<char> data;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
for (const auto &i : required_auths) {
a.insert(i);
}
}
};
/** serves the same purpose as custom_operation but also supports required posting authorities. Unlike custom_operation,
* this operation is designed to be human readable/developer friendly.
**/
struct custom_json_operation : public base_operation {
flat_set<account_name_type> required_auths;
flat_set<account_name_type> required_posting_auths;
string id; ///< must be less than 32 characters long
string json; ///< must be proper utf8 / JSON string.
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
for (const auto &i : required_auths) {
a.insert(i);
}
}
void get_required_posting_authorities(flat_set<account_name_type> &a) const {
for (const auto &i : required_posting_auths) {
a.insert(i);
}
}
};
struct custom_binary_operation : public base_operation {
flat_set<account_name_type> required_owner_auths;
flat_set<account_name_type> required_active_auths;
flat_set<account_name_type> required_posting_auths;
vector<authority> required_auths;
string id; ///< must be less than 32 characters long
vector<char> data;
void validate() const;
void get_required_owner_authorities(flat_set<account_name_type> &a) const {
for (const auto &i : required_owner_auths) {
a.insert(i);
}
}
void get_required_active_authorities(flat_set<account_name_type> &a) const {
for (const auto &i : required_active_auths) {
a.insert(i);
}
}
void get_required_posting_authorities(flat_set<account_name_type> &a) const {
for (const auto &i : required_posting_auths) {
a.insert(i);
}
}
void get_required_authorities(vector<authority> &a) const {
for (const auto &i : required_auths) {
a.push_back(i);
}
}
};
/**
* Feeds can only be published by the top N witnesses which are included in every round and are
* used to define the exchange rate between steem and the dollar.
*/
struct feed_publish_operation : public base_operation {
account_name_type publisher;
price exchange_rate;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(publisher);
}
};
/**
* This operation instructs the blockchain to start a conversion between STEEM and SBD,
* The funds are deposited after STEEMIT_CONVERSION_DELAY
*/
struct convert_operation : public base_operation {
account_name_type owner;
uint32_t requestid = 0;
asset amount;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(owner);
}
};
/**
* This operation creates a limit order and matches it against existing open orders.
*/
struct limit_order_create_operation : public base_operation {
account_name_type owner;
uint32_t orderid = 0; /// an ID assigned by owner, must be unique
asset amount_to_sell;
asset min_to_receive;
bool fill_or_kill = false;
time_point_sec expiration = time_point_sec::maximum();
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(owner);
}
price get_price() const {
return amount_to_sell / min_to_receive;
}
pair<asset_symbol_type, asset_symbol_type> get_market() const {
return amount_to_sell.symbol < min_to_receive.symbol ?
std::make_pair(amount_to_sell.symbol, min_to_receive.symbol)
:
std::make_pair(min_to_receive.symbol, amount_to_sell.symbol);
}
};
/**
* This operation is identical to limit_order_create except it serializes the price rather
* than calculating it from other fields.
*/
struct limit_order_create2_operation : public base_operation {
account_name_type owner;
uint32_t orderid = 0; /// an ID assigned by owner, must be unique
asset amount_to_sell;
bool fill_or_kill = false;
price exchange_rate;
time_point_sec expiration = time_point_sec::maximum();
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(owner);
}
price get_price() const {
return exchange_rate;
}
pair<asset_symbol_type, asset_symbol_type> get_market() const {
return exchange_rate.base.symbol < exchange_rate.quote.symbol ?
std::make_pair(exchange_rate.base.symbol, exchange_rate.quote.symbol)
:
std::make_pair(exchange_rate.quote.symbol, exchange_rate.base.symbol);
}
};
/**
* Cancels an order and returns the balance to owner.
*/
struct limit_order_cancel_operation : public base_operation {
account_name_type owner;
uint32_t orderid = 0;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(owner);
}
};
struct pow {
public_key_type worker;
digest_type input;
signature_type signature;
digest_type work;
void create(const fc::ecc::private_key &w, const digest_type &i);
void validate() const;
};
struct pow_operation : public base_operation {
account_name_type worker_account;
block_id_type block_id;
uint64_t nonce = 0;
pow work;
chain_properties_17 props;
void validate() const;
fc::sha256 work_input() const;
const account_name_type &get_worker_account() const {
return worker_account;
}
/** there is no need to verify authority, the proof of work is sufficient */
void get_required_active_authorities(flat_set<account_name_type> &a) const {
}
};
struct pow2_input {
account_name_type worker_account;
block_id_type prev_block;
uint64_t nonce = 0;
};
struct pow2 {
pow2_input input;
uint32_t pow_summary = 0;
void create(const block_id_type &prev_block, const account_name_type &account_name, uint64_t nonce);
void validate() const;
};
struct equihash_pow {
pow2_input input;
fc::equihash::proof proof;
block_id_type prev_block;
uint32_t pow_summary = 0;
void create(const block_id_type &recent_block, const account_name_type &account_name, uint32_t nonce);
void validate() const;
};
typedef fc::static_variant<pow2, equihash_pow> pow2_work;
struct pow2_operation : public base_operation {
pow2_work work;
optional<public_key_type> new_owner_key;
chain_properties_17 props;
void validate() const;
void get_required_active_authorities(flat_set<account_name_type> &a) const;
void get_required_authorities(vector<authority> &a) const {
if (new_owner_key) {
a.push_back(authority(1, *new_owner_key, 1));
}
}
};
/**
* This operation is used to report a miner who signs two blocks
* at the same time. To be valid, the violation must be reported within
* STEEMIT_MAX_WITNESSES blocks of the head block (1 round) and the
* producer must be in the ACTIVE witness set.
*
* Users not in the ACTIVE witness set should not have to worry about their
* key getting compromised and being used to produced multiple blocks so
* the attacker can report it and steel their vesting steem.
*
* The result of the operation is to transfer the full VESTING STEEM balance
* of the block producer to the reporter.
*/
struct report_over_production_operation : public base_operation {
account_name_type reporter;
signed_block_header first_block;
signed_block_header second_block;
void validate() const;
};
/**
* All account recovery requests come from a listed recovery account. This
* is secure based on the assumption that only a trusted account should be
* a recovery account. It is the responsibility of the recovery account to
* verify the identity of the account holder of the account to recover by
* whichever means they have agreed upon. The blockchain assumes identity
* has been verified when this operation is broadcast.
*
* This operation creates an account recovery request which the account to
* recover has 24 hours to respond to before the request expires and is
* invalidated.
*
* There can only be one active recovery request per account at any one time.
* Pushing this operation for an account to recover when it already has
* an active request will either update the request to a new new owner authority
* and extend the request expiration to 24 hours from the current head block
* time or it will delete the request. To cancel a request, simply set the
* weight threshold of the new owner authority to 0, making it an open authority.
*
* Additionally, the new owner authority must be satisfiable. In other words,
* the sum of the key weights must be greater than or equal to the weight
* threshold.
*
* This operation only needs to be signed by the the recovery account.
* The account to recover confirms its identity to the blockchain in
* the recover account operation.
*/
struct request_account_recovery_operation : public base_operation {
account_name_type recovery_account; ///< The recovery account is listed as the recovery account on the account to recover.
account_name_type account_to_recover; ///< The account to recover. This is likely due to a compromised owner authority.
authority new_owner_authority; ///< The new owner authority the account to recover wishes to have. This is secret
///< known by the account to recover and will be confirmed in a recover_account_operation
extensions_type extensions; ///< Extensions. Not currently used.
void get_required_active_authorities(flat_set<account_name_type> &a) const {
a.insert(recovery_account);
}
void validate() const;
};
/**
* Recover an account to a new authority using a previous authority and verification
* of the recovery account as proof of identity. This operation can only succeed
* if there was a recovery request sent by the account's recover account.
*
* In order to recover the account, the account holder must provide proof
* of past ownership and proof of identity to the recovery account. Being able
* to satisfy an owner authority that was used in the past 30 days is sufficient
* to prove past ownership. The get_owner_history function in the database API
* returns past owner authorities that are valid for account recovery.
*
* Proving identity is an off chain contract between the account holder and
* the recovery account. The recovery request contains a new authority which
* must be satisfied by the account holder to regain control. The actual process
* of verifying authority may become complicated, but that is an application
* level concern, not a blockchain concern.
*
* This operation requires both the past and future owner authorities in the
* operation because neither of them can be derived from the current chain state.
* The operation must be signed by keys that satisfy both the new owner authority
* and the recent owner authority. Failing either fails the operation entirely.
*
* If a recovery request was made inadvertantly, the account holder should
* contact the recovery account to have the request deleted.
*
* The two setp combination of the account recovery request and recover is
* safe because the recovery account never has access to secrets of the account
* to recover. They simply act as an on chain endorsement of off chain identity.
* In other systems, a fork would be required to enforce such off chain state.
* Additionally, an account cannot be permanently recovered to the wrong account.
* While any owner authority from the past 30 days can be used, including a compromised
* authority, the account can be continually recovered until the recovery account
* is confident a combination of uncompromised authorities were used to
* recover the account. The actual process of verifying authority may become