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

New trade protocol #3333

Merged
merged 46 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2c89c5d
Remove arbitration key, cleanup
chimp1984 Sep 21, 2019
edf71f2
Add BuyerAsMakerProcessDepositTxAndDelayedPayoutTxMessage
chimp1984 Sep 21, 2019
32ec5f6
Adopt trade protocol
chimp1984 Sep 21, 2019
13fda96
Remove arbitratorKey
chimp1984 Sep 21, 2019
7393262
Add new classes
chimp1984 Sep 21, 2019
5610c0e
Add new message classes
chimp1984 Sep 21, 2019
7774abe
Add new task classes
chimp1984 Sep 21, 2019
59a47d0
Renamed classed (no functional change yet)
chimp1984 Sep 21, 2019
0401045
Add lockTime
chimp1984 Sep 21, 2019
6b40c5d
Add delayedPayoutTxSignature field
chimp1984 Sep 21, 2019
db5884c
Add useReimbursementModel field
chimp1984 Sep 21, 2019
e937869
Add new classes
chimp1984 Sep 21, 2019
d8d7f34
Add setting.preferences.useReimbursementModel
chimp1984 Sep 21, 2019
2a3ba2b
Apply renamed classes (new classes not added yet)
chimp1984 Sep 21, 2019
0232ac9
Add useReimbursementModel
chimp1984 Sep 21, 2019
24761d9
Add preferences param
chimp1984 Sep 21, 2019
16a8dac
Add new methods, cleanup
chimp1984 Sep 21, 2019
1cc4205
Add daoFacade param, apply renaming
chimp1984 Sep 21, 2019
90bc4d5
Add delayedPayoutTx, lockTime and delayedPayoutTxId
chimp1984 Sep 21, 2019
d9ccf94
Remove DirectMessage interface
chimp1984 Sep 21, 2019
e75f2a5
Rename emergencySignAndPublishPayoutTx method, add new one for 2of2 MS
chimp1984 Sep 21, 2019
0b8e2e9
Apply new protocol
chimp1984 Sep 21, 2019
57f8f16
Apply new protocol
chimp1984 Sep 21, 2019
ff78aa5
Add renaming (no functional change yet)
chimp1984 Sep 21, 2019
44975be
Add new messages, apply renaming
chimp1984 Sep 21, 2019
82736de
Remove unneeded P2SHMultiSigOutputScript
chimp1984 Sep 21, 2019
3f7dfc6
Remove PREFERRED_PROJECT_CODE_STYLE
chimp1984 Sep 21, 2019
4b94412
Refactor: Rename class
chimp1984 Sep 21, 2019
5bd5d0c
Use InputsForDepositTxRequest instead of TradeMessage in handleTakeOf…
chimp1984 Sep 21, 2019
05a9703
Do not sign deposit tx if maker is seller
chimp1984 Sep 21, 2019
5aa185c
Apply new trade protocol to seller as maker version
chimp1984 Sep 21, 2019
c41b811
Apply new trade protocol
chimp1984 Sep 22, 2019
4de69a6
Set TRADE_PROTOCOL_VERSION to 2
chimp1984 Sep 22, 2019
ab63cad
Add PeerPublishedDelayedPayoutTxMessage
chimp1984 Sep 22, 2019
7988a97
Add refund agent domain
chimp1984 Sep 23, 2019
160c135
Add refundAgentNodeAddress
chimp1984 Sep 23, 2019
f12bf51
Apply refund domain
chimp1984 Sep 23, 2019
68bb842
Add refund views
chimp1984 Sep 23, 2019
912bb07
Apply refundAgent domain
chimp1984 Sep 23, 2019
8a17cc5
Support refundAgent
chimp1984 Sep 24, 2019
172330a
Remove useReimbursementModel field
chimp1984 Sep 24, 2019
1c5d9ef
Apply refundAgent payout
chimp1984 Sep 26, 2019
0300836
Handle tx info and balances
chimp1984 Sep 26, 2019
038347a
Remove mediation activation
chimp1984 Sep 26, 2019
d388d9a
Add new tac accepted flag for v1.2.0 and adjust text
chimp1984 Sep 26, 2019
a30a07e
Fix params for test classes
chimp1984 Sep 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions common/src/main/java/bisq/common/app/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static int getSubVersion(String version, int index) {
// The version no. for the objects sent over the network. A change will break the serialization of old objects.
// If objects are used for both network and database the network version is applied.
// VERSION = 0.5.0 -> P2P_NETWORK_VERSION = 1
@SuppressWarnings("ConstantConditions")
// With version 1.2.0 we change to version 2 (new trade protocol)
public static final int P2P_NETWORK_VERSION = 1;

// The version no. of the serialized data stored to disc. A change will break the serialization of old objects.
Expand All @@ -84,7 +84,8 @@ private static int getSubVersion(String version, int index) {
// A taker will check the version of the offers to see if his version is compatible.
// Offers created with the old version will become invalid and have to be canceled.
// VERSION = 0.5.0 -> TRADE_PROTOCOL_VERSION = 1
public static final int TRADE_PROTOCOL_VERSION = 1;
// Version 1.2.0 -> TRADE_PROTOCOL_VERSION = 2
public static final int TRADE_PROTOCOL_VERSION = 2;
private static int p2pMessageVersion;

public static final String BSQ_TX_VERSION = "1";
Expand Down
120 changes: 100 additions & 20 deletions common/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ message NetworkEnvelope {
CloseConnectionMessage close_connection_message = 15;
PrefixedSealedAndSignedMessage prefixed_sealed_and_signed_message = 16;

PayDepositRequest pay_deposit_request = 17;
PublishDepositTxRequest publish_deposit_tx_request = 18;
DepositTxPublishedMessage deposit_tx_published_message = 19;
InputsForDepositTxRequest inputs_for_deposit_tx_request = 17;
InputsForDepositTxResponse inputs_for_deposit_tx_response = 18;
DepositTxMessage deposit_tx_message = 19;
CounterCurrencyTransferStartedMessage counter_currency_transfer_started_message = 20;
PayoutTxPublishedMessage payout_tx_published_message = 21;

Expand Down Expand Up @@ -70,6 +70,11 @@ message NetworkEnvelope {
BundleOfEnvelopes bundle_of_envelopes = 43;
MediatedPayoutTxSignatureMessage mediated_payout_tx_signature_message = 44;
MediatedPayoutTxPublishedMessage mediated_payout_tx_published_message = 45;

DelayedPayoutTxSignatureRequest delayed_payout_tx_signature_request = 46;
DelayedPayoutTxSignatureResponse delayed_payout_tx_signature_response = 47;
DepositTxAndDelayedPayoutTxMessage deposit_tx_and_delayed_payout_tx_message = 48;
PeerPublishedDelayedPayoutTxMessage peer_published_delayed_payout_tx_message = 49;
}
}

Expand Down Expand Up @@ -144,6 +149,7 @@ message OfferAvailabilityResponse {
string uid = 4;
NodeAddress arbitrator = 5;
NodeAddress mediator = 6;
NodeAddress refund_agent = 7;
}

message RefreshOfferMessage {
Expand Down Expand Up @@ -197,7 +203,7 @@ message PrefixedSealedAndSignedMessage {

// trade

message PayDepositRequest {
message InputsForDepositTxRequest {
string trade_id = 1;
NodeAddress sender_node_address = 2;
int64 trade_amount = 3;
Expand All @@ -221,9 +227,11 @@ message PayDepositRequest {
string uid = 21;
bytes account_age_witness_signature_of_offer_id = 22;
int64 current_date = 23;
repeated NodeAddress accepted_refund_agent_node_addresses = 24;
NodeAddress refund_agent_node_address = 25;
}

message PublishDepositTxRequest {
message InputsForDepositTxResponse {
string trade_id = 1;
PaymentAccountPayload maker_payment_account_payload = 2;
string maker_account_id = 3;
Expand All @@ -237,13 +245,42 @@ message PublishDepositTxRequest {
string uid = 11;
bytes account_age_witness_signature_of_prepared_deposit_tx = 12;
int64 current_date = 13;
int64 lock_time = 14;
}

message DepositTxPublishedMessage {
string trade_id = 1;
bytes deposit_tx = 2;
message DelayedPayoutTxSignatureRequest {
string uid = 1;
string trade_id = 2;
NodeAddress sender_node_address = 3;
bytes delayed_payout_tx = 4;
}

message DelayedPayoutTxSignatureResponse {
string uid = 1;
string trade_id = 2;
NodeAddress sender_node_address = 3;
bytes delayed_payout_tx_signature = 4;
}

message DepositTxAndDelayedPayoutTxMessage {
string uid = 1;
string trade_id = 2;
NodeAddress sender_node_address = 3;
bytes deposit_tx = 4;
bytes delayed_payout_tx = 5;
}

message DepositTxMessage {
string uid = 1;
string trade_id = 2;
NodeAddress sender_node_address = 3;
bytes deposit_tx = 4;
}

message PeerPublishedDelayedPayoutTxMessage {
string uid = 1;
string trade_id = 2;
NodeAddress sender_node_address = 3;
string uid = 4;
}

message CounterCurrencyTransferStartedMessage {
Expand Down Expand Up @@ -279,8 +316,8 @@ message MediatedPayoutTxPublishedMessage {

message MediatedPayoutTxSignatureMessage {
string uid = 1;
bytes tx_signature = 2;
string trade_id = 3;
bytes tx_signature = 2;
NodeAddress sender_node_address = 4;
}

Expand All @@ -290,6 +327,7 @@ enum SupportType {
ARBITRATION = 0;
MEDIATION = 1;
TRADE = 2;
REFUND = 3;
}

message OpenNewDisputeMessage {
Expand Down Expand Up @@ -431,7 +469,7 @@ message Peer {
message PubKeyRing {
bytes signature_pub_key_bytes = 1;
bytes encryption_pub_key_bytes = 2;
reserved 3; // WAS: string pgp_pub_key_as_pem = 3;
reserved 3; // WAS: string pgp_pub_key_as_pem = 3;
}

message SealedAndSigned {
Expand All @@ -457,6 +495,7 @@ message StoragePayload {
MailboxStoragePayload mailbox_storage_payload = 6;
OfferPayload offer_payload = 7;
TempProposalPayload temp_proposal_payload = 8;
RefundAgent refund_agent = 9;
}
}

Expand Down Expand Up @@ -550,6 +589,18 @@ message Mediator {
map<string, string> extra_data = 9;
}

message RefundAgent {
NodeAddress node_address = 1;
repeated string language_codes = 2;
int64 registration_date = 3;
string registration_signature = 4;
bytes registration_pub_key = 5;
PubKeyRing pub_key_ring = 6;
string email_address = 7;
string info = 8;
map<string, string> extra_data = 9;
}

message Filter {
repeated string banned_node_address = 1;
repeated string banned_offer_ids = 2;
Expand All @@ -568,6 +619,7 @@ message Filter {
string disable_dao_below_version = 15;
string disable_trade_below_version = 16;
repeated string mediators = 17;
repeated string refundAgents = 18;
}

// not used anymore from v0.6 on. But leave it for receiving TradeStatistics objects from older
Expand Down Expand Up @@ -708,6 +760,8 @@ message Dispute {
bool is_closed = 21;
DisputeResult dispute_result = 22;
string dispute_payout_tx_id = 23;
SupportType support_type = 24;
string mediators_dispute_result = 25;
}

message Attachment {
Expand Down Expand Up @@ -774,6 +828,8 @@ message Contract {
bytes maker_multi_sig_pub_key = 17;
bytes taker_multi_sig_pub_key = 18;
NodeAddress mediator_node_address = 19;
int64 lock_time = 20;
NodeAddress refund_agent_node_address = 21;
}

message RawTransactionInput {
Expand All @@ -793,6 +849,7 @@ enum AvailabilityResult {
NO_MEDIATORS = 7;
USER_IGNORED = 8;
MISSING_MANDATORY_CAPABILITY = 9;
NO_REFUND_AGENTS = 10;
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1074,6 +1131,7 @@ message PersistableEnvelope {
UnconfirmedBsqChangeOutputList unconfirmed_bsq_change_output_list = 27;
SignedWitnessStore signed_witness_store = 28;
MediationDisputeList mediation_dispute_list = 29;
RefundDisputeList refund_dispute_list = 30;
}
}

Expand Down Expand Up @@ -1198,6 +1256,7 @@ message OpenOffer {
State state = 2;
NodeAddress arbitrator_node_address = 3;
NodeAddress mediator_node_address = 4;
NodeAddress refund_agent_node_address = 5;
}

message Tradable {
Expand All @@ -1220,13 +1279,13 @@ message Trade {
MAKER_STORED_IN_MAILBOX_PUBLISH_DEPOSIT_TX_REQUEST = 5;
MAKER_SEND_FAILED_PUBLISH_DEPOSIT_TX_REQUEST = 6;
TAKER_RECEIVED_PUBLISH_DEPOSIT_TX_REQUEST = 7;
TAKER_PUBLISHED_DEPOSIT_TX = 8;
TAKER_SENT_DEPOSIT_TX_PUBLISHED_MSG = 9;
TAKER_SAW_ARRIVED_DEPOSIT_TX_PUBLISHED_MSG = 10;
TAKER_STORED_IN_MAILBOX_DEPOSIT_TX_PUBLISHED_MSG = 11;
TAKER_SEND_FAILED_DEPOSIT_TX_PUBLISHED_MSG = 12;
MAKER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG = 13;
MAKER_SAW_DEPOSIT_TX_IN_NETWORK = 14;
SELLER_PUBLISHED_DEPOSIT_TX = 8;
SELLER_SENT_DEPOSIT_TX_PUBLISHED_MSG = 9;
SELLER_SAW_ARRIVED_DEPOSIT_TX_PUBLISHED_MSG = 10;
SELLER_STORED_IN_MAILBOX_DEPOSIT_TX_PUBLISHED_MSG = 11;
SELLER_SEND_FAILED_DEPOSIT_TX_PUBLISHED_MSG = 12;
BUYER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG = 13;
BUYER_SAW_DEPOSIT_TX_IN_NETWORK = 14;
DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN = 15;
BUYER_CONFIRMED_IN_UI_FIAT_PAYMENT_INITIATED = 16;
BUYER_SENT_FIAT_PAYMENT_INITIATED_MSG = 17;
Expand Down Expand Up @@ -1266,6 +1325,9 @@ message Trade {
MEDIATION_REQUESTED = 5;
MEDIATION_STARTED_BY_PEER = 6;
MEDIATION_CLOSED = 7;
REFUND_REQUESTED = 8;
REFUND_REQUEST_STARTED_BY_PEER = 9;
REFUND_REQUEST_CLOSED = 10;
}

enum TradePeriodState {
Expand Down Expand Up @@ -1305,6 +1367,11 @@ message Trade {
string counter_currency_tx_id = 28;
repeated ChatMessage chat_message = 29;
MediationResultState mediation_result_state = 30;
int64 lock_time = 31;
string delayed_payout_tx_id = 32;
NodeAddress refund_agent_node_address = 33;
PubKeyRing refund_agent_pub_key_ring = 34;
RefundResultState refund_result_state = 35;
}

message BuyerAsMakerTrade {
Expand All @@ -1330,8 +1397,8 @@ message ProcessModel {
PubKeyRing pub_key_ring = 4;
string take_offer_fee_tx_id = 5;
bytes payout_tx_signature = 6;
repeated NodeAddress taker_accepted_arbitrator_node_addresses = 7;
repeated NodeAddress taker_accepted_mediator_node_addresses = 8;
reserved 7; // Not used anymore
reserved 8; // Not used anymore
bytes prepared_deposit_tx = 9;
repeated RawTransactionInput raw_transaction_inputs = 10;
int64 change_output_value = 11;
Expand Down Expand Up @@ -1376,6 +1443,10 @@ message MediationDisputeList {
repeated Dispute dispute = 1;
}

message RefundDisputeList {
repeated Dispute dispute = 1;
}

enum MediationResultState {
PB_ERROR_MEDIATION_RESULT = 0;
UNDEFINED_MEDIATION_RESULT = 1;
Expand All @@ -1395,6 +1466,12 @@ enum MediationResultState {
PAYOUT_TX_SEEN_IN_NETWORK = 15;
}

//todo
enum RefundResultState {
PB_ERROR_REFUND_RESULT = 0;
UNDEFINED_REFUND_RESULT = 1;
}

///////////////////////////////////////////////////////////////////////////////////////////
// Preferences
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1454,6 +1531,7 @@ message PreferencesPayload {
double buyer_security_deposit_as_percent_for_crypto = 52;
int32 block_notify_port = 53;
int32 css_theme = 54;
bool tac_accepted_v120 = 55;
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -1474,6 +1552,8 @@ message UserPayload {
Mediator registered_mediator = 11;
PriceAlertFilter price_alert_filter = 12;
repeated MarketAlertFilter market_alert_filters = 13;
repeated RefundAgent accepted_refund_agents = 14;
RefundAgent registered_refund_agent = 15;
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading