From 8271920943063665df49f119853ff971cbfedc7f Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sun, 20 Feb 2022 20:20:33 -0300 Subject: [PATCH 01/14] New comments through "message TxInfo { ... }" --- proto/src/main/proto/grpc.proto | 204 ++++++++++++++++++-------------- 1 file changed, 118 insertions(+), 86 deletions(-) diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index 62672019305..ea4b2a99eea 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -47,11 +47,11 @@ service Help { } message GetMethodHelpRequest { - string methodName = 1; // CLI command name. + string methodName = 1; // The CLI command name. } message GetMethodHelpReply { - string methodHelp = 1; // Man page for CLI command. + string methodHelp = 1; // The man page for the CLI command. } /* @@ -96,7 +96,7 @@ service Offers { // Edit an open offer. rpc EditOffer (EditOfferRequest) returns (EditOfferReply) { } - // Cancel (remove) an open offer. + // Cancel an open offer; remove it from the offer book. rpc CancelOffer (CancelOfferRequest) returns (CancelOfferReply) { } } @@ -108,10 +108,10 @@ message GetOfferCategoryRequest { message GetOfferCategoryReply { enum OfferCategory { - UNKNOWN = 0; - FIAT = 1; - ALTCOIN = 2; - BSQ_SWAP = 3; + UNKNOWN = 0; // An invalid offer category probably indicates a software bug. + FIAT = 1; // Indicates offer is to BUY or SELL BTC with a fiat currency. + ALTCOIN = 2; // Indicates offer is to BUY or SELL BTC with an altcoin. + BSQ_SWAP = 3; // Indicates offer is to swap BTC for BSQ. } OfferCategory offerCategory = 1; } @@ -361,7 +361,7 @@ message AvailabilityResultWithDescription { * The PaymentAccounts service provides rpc methods for creating fiat and crypto currency payment accounts. */ service PaymentAccounts { - // Create a fiat payment account, providing details in a json form. + // Create a fiat payment account, providing details in a json form generated by rpc method GetPaymentAccountForm. rpc CreatePaymentAccount (CreatePaymentAccountRequest) returns (CreatePaymentAccountReply) { } // Get list of all saved fiat payment accounts. @@ -370,7 +370,7 @@ service PaymentAccounts { // Get list of all supported Bisq payment methods. rpc GetPaymentMethods (GetPaymentMethodsRequest) returns (GetPaymentMethodsReply) { } - // Get a json template file for a supported Bisq payment method. + // Get a json template file for a supported Bisq payment method. Fill in the form and call rpc method CreatePaymentAccount. rpc GetPaymentAccountForm (GetPaymentAccountFormRequest) returns (GetPaymentAccountFormReply) { } // Create a crypto currency (altcoin) payment account. @@ -382,51 +382,52 @@ service PaymentAccounts { } message CreatePaymentAccountRequest { - string paymentAccountForm = 1; + string paymentAccountForm = 1; // File path of filled json payment account form. } message CreatePaymentAccountReply { - PaymentAccount paymentAccount = 1; + PaymentAccount paymentAccount = 1; // The new payment account. } message GetPaymentAccountsRequest { } message GetPaymentAccountsReply { - repeated PaymentAccount paymentAccounts = 1; + repeated PaymentAccount paymentAccounts = 1; // All user's saved payment accounts. } message GetPaymentMethodsRequest { } message GetPaymentMethodsReply { - repeated PaymentMethod paymentMethods = 1; + repeated PaymentMethod paymentMethods = 1; // Ids of all supported Bisq fiat payment methods. } message GetPaymentAccountFormRequest { - string paymentMethodId = 1; + string paymentMethodId = 1; // Payment method id determining content of the requested payment account form. } message GetPaymentAccountFormReply { + // An empty payment account json form to be filled out and passed to rpc method CreatePaymentAccount. string paymentAccountFormJson = 1; } message CreateCryptoCurrencyPaymentAccountRequest { - string accountName = 1; - string currencyCode = 2; - string address = 3; - bool tradeInstant = 4; + string accountName = 1; // The name of the altcoin payment account. Uniqueness is not enforced. + string currencyCode = 2; // The altcoin currency code. + string address = 3; // The altcoin receiving address. + bool tradeInstant = 4; // Whether the altcoin payment account is an instant account or not. } message CreateCryptoCurrencyPaymentAccountReply { - PaymentAccount paymentAccount = 1; + PaymentAccount paymentAccount = 1; // The new altcoin payment account. } message GetCryptoCurrencyPaymentMethodsRequest { } message GetCryptoCurrencyPaymentMethodsReply { - repeated PaymentMethod paymentMethods = 1; + repeated PaymentMethod paymentMethods = 1; // Ids of all supported Bisq altcoin payment methods. } service Price { @@ -436,11 +437,11 @@ service Price { } message MarketPriceRequest { - string currencyCode = 1; + string currencyCode = 1; // The three letter currency code. } message MarketPriceReply { - double price = 1; + double price = 1; // The most recently available market price. } /* @@ -476,22 +477,22 @@ message StopReply { * The Trades service provides rpc methods for taking, executing, and listing trades. */ service Trades { - // Get an open trade with a trade-id. + // Get a currently open trade. rpc GetTrade (GetTradeRequest) returns (GetTradeReply) { } - // Get all open or historical trades. + // Get currently open, or historical trades (closed or failed). rpc GetTrades (GetTradesRequest) returns (GetTradesReply) { } // Take an open offer. rpc TakeOffer (TakeOfferRequest) returns (TakeOfferReply) { } - // Send a 'payment started' message to a trading peer (seller). + // Send a 'payment started' message to a trading peer (the BTC seller). rpc ConfirmPaymentStarted (ConfirmPaymentStartedRequest) returns (ConfirmPaymentStartedReply) { } - // Send a 'payment received' message to a trading peer (buyer). + // Send a 'payment received' message to a trading peer (the BTC buyer). rpc ConfirmPaymentReceived (ConfirmPaymentReceivedRequest) returns (ConfirmPaymentReceivedReply) { } - // Close a completed trade (moves it to trade history). + // Close a completed trade; move it to trade history. rpc CloseTrade (CloseTradeRequest) returns (CloseTradeReply) { } // Fail an open trade. @@ -506,173 +507,204 @@ service Trades { } message TakeOfferRequest { - string offerId = 1; - string paymentAccountId = 2; - string takerFeeCurrencyCode = 3; + string offerId = 1; // The unique identifier of the offer being taken. + string paymentAccountId = 2; // The unique identifier of the payment account used to take offer.. + string takerFeeCurrencyCode = 3; // The code of the currency (BSQ or BTC) used to pay the taker's Bisq trade fee. } message TakeOfferReply { - TradeInfo trade = 1; - AvailabilityResultWithDescription failureReason = 2; + TradeInfo trade = 1; // The new trade. + AvailabilityResultWithDescription failureReason = 2; // The reason the offer could not be taken. } message ConfirmPaymentStartedRequest { - string tradeId = 1; + string tradeId = 1; // The unique identifier of the open trade. } message ConfirmPaymentStartedReply { } message ConfirmPaymentReceivedRequest { - string tradeId = 1; + string tradeId = 1; // The unique identifier of the open trade. } message ConfirmPaymentReceivedReply { } message GetTradeRequest { - string tradeId = 1; + string tradeId = 1; // The unique identifier of the trade. } message GetTradeReply { - TradeInfo trade = 1; + TradeInfo trade = 1; // The unique identifier of the trade. } message GetTradesRequest { + // Rpc method GetTrades parameter determining what category of trade list is is being requested. enum Category { - OPEN = 0; - CLOSED = 1; - FAILED = 2; + OPEN = 0; // Get all currently open trades. + CLOSED = 1; // Get all completed trades. + FAILED = 2; // Get all failed trades. } Category category = 1; } message GetTradesReply { - repeated TradeInfo trades = 1; + repeated TradeInfo trades = 1; // All trades for GetTradesRequest.Category. } message CloseTradeRequest { - string tradeId = 1; + string tradeId = 1; // The unique identifier of the trade. } message CloseTradeReply { } message FailTradeRequest { - string tradeId = 1; + string tradeId = 1; // The unique identifier of the trade. } message FailTradeReply { } message UnFailTradeRequest { - string tradeId = 1; + string tradeId = 1; // The unique identifier of the trade. } message UnFailTradeReply { } message WithdrawFundsRequest { - string tradeId = 1; - string address = 2; - string memo = 3; + string tradeId = 1; // The unique identifier of the trade. + string address = 2; // The receiver's bitcoin wallet address. + string memo = 3; // An optional memo saved with the sent btc transaction. } message WithdrawFundsReply { } message TradeInfo { + // The original offer. OfferInfo offer = 1; + // The unique identifier of the trade. string tradeId = 2; + // An abbreviation of unique identifier of the trade. It cannot be used as parameter to rpc methods GetTrade, + // ConfirmPaymentStarted, CloseTrade, etc., but it may be useful while interacting with support or trading peers. string shortId = 3; + // The creation date of the trade as a long: the number of milliseconds that have elapsed since January 1, 1970. uint64 date = 4; + // A brief description of the user's role in the trade, i.e., an offer maker or taker, a BTC buyer or seller. string role = 5; + // Whether the offer taker's Bisq trade fee was paid in BTC or not (BSQ). bool isCurrencyForTakerFeeBtc = 6; + // The bitcoin miner transaction fee in satoshis. uint64 txFeeAsLong = 7; + // The offer taker's Bisq trade fee in satoshis. uint64 takerFeeAsLong = 8; + // The bitcoin transaction id for offer taker's Bisq trade fee. string takerFeeTxId = 9; + // The bitcoin transaction id for the offer taker's security deposit. string depositTxId = 10; + // The bitcoin transaction id for trade payout. string payoutTxId = 11; + // The trade payout amount in satoshis. uint64 tradeAmountAsLong = 12; // For fiat trades: the fiat price for 1 BTC to 4 decimal places, e.g., 41000.50 EUR is "41000.5000". // For altcoin trades: the altcoin price for 1 BTC to 8 decimal places, e.g., 0.5 BTC is "0.50000000". string tradePrice = 13; + // The trading peer's node address. string tradingPeerNodeAddress = 14; + // The internal state of the trade. (TODO Needs more explanation.) string state = 15; + // The internal phase of the trade. (TODO Needs more explanation.) string phase = 16; + // How much of the trade protocol's time limit has elapsed. (TODO Needs more explanation.) string tradePeriodState = 17; + // Whether the trade's security deposit bitcoin transaction has been broadcast, or not. bool isDepositPublished = 18; + // Whether the trade's security deposit bitcoin transaction has been confirmed at least once, or not. bool isDepositConfirmed = 19; + // Whether the trade's 'start payment' message has been sent by the BTC buyer, or not. + // (TODO Rename field to isPaymentSent because payment could be made in altcoin.) bool isFiatSent = 20; + // Whether the trade's 'payment received' message has been sent by the BTC seller, or not. + // (TODO Rename field to isPaymentReceived because payment could be made in altcoin.) bool isFiatReceived = 21; + // Whether the trade's payout bitcoin transaction has been confirmed at least once, or not. bool isPayoutPublished = 22; + // Whether the trade's payout has been completed and the trade is now closed, or not. + // (TODO Rename field to isClosed, or isCompleted because payment could be made in altcoin.) bool isWithdrawn = 23; + // The entire trade contract as a json string. string contractAsJson = 24; + // The summary of the trade contract. ContractInfo contract = 25; // The volume of currency traded for BTC. string tradeVolume = 26; + // The details specific to the BSQ swap trade. If the trade is not a BSQ swap, this field should be ignored. BsqSwapTradeInfo bsqSwapTradeInfo = 28; // Needed by open/closed/failed trade list items. string closingStatus = 29; } message ContractInfo { - string buyerNodeAddress = 1; - string sellerNodeAddress = 2; - string mediatorNodeAddress = 3; - string refundAgentNodeAddress = 4; - bool isBuyerMakerAndSellerTaker = 5; - string makerAccountId = 6; - string takerAccountId = 7; - PaymentAccountPayloadInfo makerPaymentAccountPayload = 8; - PaymentAccountPayloadInfo takerPaymentAccountPayload = 9; - string makerPayoutAddressString = 10; - string takerPayoutAddressString = 11; - uint64 lockTime = 12; + string buyerNodeAddress = 1; // The BTC buyer peer's node address. + string sellerNodeAddress = 2; // The BTC seller peer's node address. + string mediatorNodeAddress = 3; // If the trade was disputed, the Bisq mediator's node address. + string refundAgentNodeAddress = 4; // If a trade refund was requested, the Bisq refund agent's node address. + bool isBuyerMakerAndSellerTaker = 5; // Whether the BTC buyer created the original offer, or not. + string makerAccountId = 6; // The offer maker's payment account id. + string takerAccountId = 7; // The offer taker's payment account id. + PaymentAccountPayloadInfo makerPaymentAccountPayload = 8; // A summary of the offer maker's payment account. + PaymentAccountPayloadInfo takerPaymentAccountPayload = 9; // A summary of the offer taker's payment account. + string makerPayoutAddressString = 10; // The offer maker's BTC payout address. + string takerPayoutAddressString = 11; // The offer taker's BTC payout address. + uint64 lockTime = 12; // TODO } /* * BSQ Swap protocol specific fields not common to Bisq v1 trade protocol fields. */ message BsqSwapTradeInfo { - string txId = 1; - uint64 bsqTradeAmount = 2; - uint64 btcTradeAmount = 3; - uint64 bsqMakerTradeFee = 4; - uint64 bsqTakerTradeFee = 5; - uint64 txFeePerVbyte = 6; - string makerBsqAddress = 7; - string makerBtcAddress = 8; - string takerBsqAddress = 9; - string takerBtcAddress = 10; - uint64 numConfirmations = 11; - string errorMessage = 12; - uint64 payout = 13; - uint64 swapPeerPayout = 14; + string txId = 1; // The BSQ swap's bitcoin transaction id. + uint64 bsqTradeAmount = 2; // The amount of BSQ swapped in satoshis. + uint64 btcTradeAmount = 3; // The amount of BTC swapped in satoshis. + uint64 bsqMakerTradeFee = 4; // The swap offer maker's BSQ trade fee. + uint64 bsqTakerTradeFee = 5; // The swap offer taker's BSQ trade fee. + uint64 txFeePerVbyte = 6; // The swap transaction's bitcoin transaction id. + string makerBsqAddress = 7; // The swap offer maker's BSQ wallet address. + string makerBtcAddress = 8; // The swap offer maker's BTC wallet address. + string takerBsqAddress = 9; // The swap offer taker's BSQ wallet address. + string takerBtcAddress = 10; // The swap offer taker's BTC wallet address. + uint64 numConfirmations = 11; // The confirmations count for the completed swap's bitcoin transaction. + string errorMessage = 12; // An explanation for a failure to complete the swap. + uint64 payout = 13; // The amount of the user's payout in satoshis. (TODO explanation about miner fee vs trade fee) + uint64 swapPeerPayout = 14; // The amount of the peer's payout in satoshis. (TODO explanation about miner fee vs trade fee) } message PaymentAccountPayloadInfo { - string id = 1; - string paymentMethodId = 2; - string address = 3; + string id = 1; // The unique identifier of the payment account. + string paymentMethodId = 2; // The unique identifier of the payment method. + string address = 3; // The optional altcoin wallet address associated with the (altcoin) payment account. } message TxFeeRateInfo { - bool useCustomTxFeeRate = 1; - uint64 customTxFeeRate = 2; - uint64 feeServiceRate = 3; + bool useCustomTxFeeRate = 1; // Whether the daemon's custom btc transaction fee rate preference is set, or not. + uint64 customTxFeeRate = 2; // The daemon's custom btc transaction fee rate preference, in sats/byte. + uint64 feeServiceRate = 3; // The Bisq network's most recently available btc transaction fee rate, in sats/byte. + // The date of the most recent Bisq network fee rate request as a long: the number of milliseconds that have elapsed since January 1, 1970. uint64 lastFeeServiceRequestTs = 4; - uint64 minFeeServiceRate = 5; + uint64 minFeeServiceRate = 5; // The Bisq network's minimum btc transaction fee rate, in sats/byte. } message TxInfo { - string txId = 1; - uint64 inputSum = 2; - uint64 outputSum = 3; - uint64 fee = 4; - int32 size = 5; - bool isPending = 6; - string memo = 7; + string txId = 1; // The bitcoin transaction id. + uint64 inputSum = 2; // The sum of the bitcoin transactions input values in satoshis. + uint64 outputSum = 3; // The sum of the bitcoin transactions output values in satoshis. + uint64 fee = 4; // The bitcoin transaction's miner fee in satoshis. + int32 size = 5; // The bitcoin transaction's size in bytes. + bool isPending = 6; // Whether the bitcoin transaction has been confirmed at least one time, or not. + string memo = 7; // An optional memo associated with the bitcoin transaction. } /* From fcd9c7e4d30bd868f695e0d86a2876fefcfca617 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Mon, 21 Feb 2022 07:48:02 -0300 Subject: [PATCH 02/14] Finish 1st full pass of documenting grpc.proto for API reference site --- proto/src/main/proto/grpc.proto | 117 ++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 43 deletions(-) diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index ea4b2a99eea..4a5840d215e 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -713,7 +713,7 @@ message TxInfo { * an encryption password on a a wallet, and unlocking / locking an encrypted wallet. */ service Wallets { - // Get current BSQ and BTC balances. + // Get the Bisq wallet's current BSQ and BTC balances. rpc GetBalances (GetBalancesRequest) returns (GetBalancesReply) { } // Get BTC balance for a wallet address. @@ -722,95 +722,112 @@ service Wallets { // Get an unused BSQ wallet address. rpc GetUnusedBsqAddress (GetUnusedBsqAddressRequest) returns (GetUnusedBsqAddressReply) { } - // Send BSQ to an address. + // Send an amount of BSQ to an external address. rpc SendBsq (SendBsqRequest) returns (SendBsqReply) { } - // Send BSQ to an address. + // Send an amount of BTC to an external address. rpc SendBtc (SendBtcRequest) returns (SendBtcReply) { } - // Verify a specific amount of BSQ was received by a BSQ wallet address. (TODO change method name?) + // Verify a specific amount of BSQ was received by a BSQ wallet address. + // This is a problematic way of verifying BSQ payment has been received for a v1 trade protocol BSQ-BTC trade, + // which has been solved by the introduction of BSQ swap trades, which use a different, unused BSQ address for each trade. rpc VerifyBsqSentToAddress (VerifyBsqSentToAddressRequest) returns (VerifyBsqSentToAddressReply) { } - // Get most recently available BTC network tx fee, or custom fee rate if set. + // Get the most recently available Bisq network's bitcoin miner transaction fee rate, or custom fee rate if set. rpc GetTxFeeRate (GetTxFeeRateRequest) returns (GetTxFeeRateReply) { } - // Set custom tx fee rate. + // Set the Bisq daemon's custom bitcoin miner transaction fee rate, in sats/byte.. rpc SetTxFeeRatePreference (SetTxFeeRatePreferenceRequest) returns (SetTxFeeRatePreferenceReply) { } - // Remove custom tx fee rate, revert to using BTC network tx fee rate. + // Remove the custom bitcoin miner transaction fee rate; revert to the Bisq network's bitcoin miner transaction fee rate. rpc UnsetTxFeeRatePreference (UnsetTxFeeRatePreferenceRequest) returns (UnsetTxFeeRatePreferenceReply) { } - // Get a BTC tx with a transaction-id. + // Get a bitcoin transaction summary. rpc GetTransaction (GetTransactionRequest) returns (GetTransactionReply) { } - // Get all BTC receiving address in the wallet. + // Get all bitcoin receiving address in the Bisq BTC wallet. rpc GetFundingAddresses (GetFundingAddressesRequest) returns (GetFundingAddressesReply) { } - // Set wallet encryption password. + // Set the Bisq wallet's encryption password for a time period in seconds. An unlocked wallet will automatically + // lock itself after the timeout period has expired, or a LockWallet request has been made, whichever is first. + // An unlocked wallet's timeout setting can be overridden by subsequent SetWalletPassword calls. rpc SetWalletPassword (SetWalletPasswordRequest) returns (SetWalletPasswordReply) { } - // Remove wallet encryption password. + // Remove the encryption password from the Bisq wallet. rpc RemoveWalletPassword (RemoveWalletPasswordRequest) returns (RemoveWalletPasswordReply) { } - // Lock unlocked, encrypted wallet. + // Lock an encrypted Bisq wallet before the UnlockWallet rpc method's timeout period has expired. rpc LockWallet (LockWalletRequest) returns (LockWalletReply) { } - // Unlock encrypted wallet before executing wallet sensitive methods: - // createoffer, takeoffer, getbalances, etc. + // Unlock a Bisq encrypted wallet before calling wallet sensitive rpc methods: CreateOffer, TakeOffer, GetBalances, etc. rpc UnlockWallet (UnlockWalletRequest) returns (UnlockWalletReply) { } } message GetBalancesRequest { - string currencyCode = 1; + string currencyCode = 1; // The Bisq wallet currency (BSQ or BTC) for the balances request. } message GetBalancesReply { - BalancesInfo balances = 1; + BalancesInfo balances = 1; // The summary of Bisq wallet's BSQ and BTC balances. } message GetAddressBalanceRequest { - string address = 1; + string address = 1; // The BTC wallet address being queried. } message GetAddressBalanceReply { - AddressBalanceInfo addressBalanceInfo = 1; + AddressBalanceInfo addressBalanceInfo = 1; // The BTC wallet address with its balance summary. } message GetUnusedBsqAddressRequest { } message GetUnusedBsqAddressReply { - string address = 1; + string address = 1; // The BSQ wallet's unused address. } message SendBsqRequest { + // The external BSQ wallet address. string address = 1; + // The amount being sent to the external BSQ wallet address, as a string in "#######,##" format. string amount = 2; + // An optional bitcoin miner transaction fee rate, in sats/byte. If not defined, Bisq will revert + // to the custom transaction fee rate preference, if set, else the common Bisq network fee rate. string txFeeRate = 3; } message SendBsqReply { + // The summary of a bitcoin transaction. (BSQ is a colored coin, and transacted on the bitcoin blockchain.) TxInfo txInfo = 1; } message SendBtcRequest { + // The external bitcoin address. string address = 1; + // The amount of BTC to send to the external address, as a string in "##.########" (BTC unit) format. string amount = 2; + // An optional bitcoin miner transaction fee rate, in sats/byte. If not defined, Bisq will revert + // to the custom transaction fee rate preference, if set, else the common Bisq network fee rate. string txFeeRate = 3; + // An optional memo associated with the bitcoin transaction. string memo = 4; } message SendBtcReply { - TxInfo txInfo = 1; + TxInfo txInfo = 1; // The summary of a bitcoin transaction. } message VerifyBsqSentToAddressRequest { - string address = 1; - string amount = 2; + string address = 1; // The internal BSQ wallet address. + string amount = 2; // The amount supposedly sent to the BSQ wallet address, as a string in "#######,##" format. } message VerifyBsqSentToAddressReply { + // Whether a specific BSQ wallet address has received a specific amount of BSQ. If the same address has received + // the same amount of BSQ more than once, a true value does not indicate payment has been made for a v1 protocol + // BSQ-BTC trade. This BSQ payment verification problem is solved with BSQ swaps, which use a different BSQ + // address for each swap transaction. bool isAmountReceived = 1; } @@ -818,7 +835,7 @@ message GetTxFeeRateRequest { } message GetTxFeeRateReply { - TxFeeRateInfo txFeeRateInfo = 1; + TxFeeRateInfo txFeeRateInfo = 1; // The summary of the most recently available bitcoin transaction fee rates. } message SetTxFeeRatePreferenceRequest { @@ -826,14 +843,14 @@ message SetTxFeeRatePreferenceRequest { } message SetTxFeeRatePreferenceReply { - TxFeeRateInfo txFeeRateInfo = 1; + TxFeeRateInfo txFeeRateInfo = 1; // The summary of the most recently available bitcoin transaction fee rates. } message UnsetTxFeeRatePreferenceRequest { } message UnsetTxFeeRatePreferenceReply { - TxFeeRateInfo txFeeRateInfo = 1; + TxFeeRateInfo txFeeRateInfo = 1; // The summary of the most recently available bitcoin transaction fee rates. } message GetTransactionRequest { @@ -841,26 +858,26 @@ message GetTransactionRequest { } message GetTransactionReply { - TxInfo txInfo = 1; + TxInfo txInfo = 1; // The summary of a bitcoin transaction. } message GetFundingAddressesRequest { } message GetFundingAddressesReply { - repeated AddressBalanceInfo addressBalanceInfo = 1; + repeated AddressBalanceInfo addressBalanceInfo = 1; // The list of BTC wallet addresses with their balances. } message SetWalletPasswordRequest { - string password = 1; - string newPassword = 2; + string password = 1; // The new password for encrypting an unencrypted Bisq wallet. + string newPassword = 2; // The new password for encrypting an already encrypted Bisq wallet (a password override). } message SetWalletPasswordReply { } message RemoveWalletPasswordRequest { - string password = 1; + string password = 1; // The Bisq wallet's current encryption password. } message RemoveWalletPasswordReply { @@ -873,43 +890,57 @@ message LockWalletReply { } message UnlockWalletRequest { - string password = 1; - uint64 timeout = 2; + string password = 1; // The Bisq wallet's encryption password. + uint64 timeout = 2; // The Bisq wallet unlock time period, in seconds. } message UnlockWalletReply { } -/* Field names are shortened for readability's sake, i.e., -* balancesInfo.getBtc().getAvailableBalance() is cleaner than -* balancesInfo.getBtcBalanceInfo().getAvailableBalance(). -*/ message BalancesInfo { - BsqBalanceInfo bsq = 1; - BtcBalanceInfo btc = 2; + BsqBalanceInfo bsq = 1; // BSQ wallet balance information. + BtcBalanceInfo btc = 2; // BTC wallet balance information. } message BsqBalanceInfo { + // The BSQ amount currently available to send to other addresses at the user's discretion, in satoshis. uint64 availableConfirmedBalance = 1; + // The BSQ amount currently being used in a send transaction, in satoshis. Unverified BSQ balances are not spendable, + // but are often quickly returned to the availableConfirmedBalance as soon as the send transaction has been broadcast. + // (TODO Clarify meaning of unverifiedBalance.) uint64 unverifiedBalance = 2; + // The BSQ transaction change amount tied up in an unconfirmed transaction, remaining unspendable until the change + // is returned to the availableConfirmedBalance. + // (TODO Clarify meaning of unverifiedBalance.) uint64 unconfirmedChangeBalance = 3; + // The locked BSQ amount held by DAO voting transaction. uint64 lockedForVotingBalance = 4; + // The locked BSQ amount held by DAO bonding transaction. uint64 lockupBondsBalance = 5; + // The BSQ amount received during a time-based DAO bonding release transaction. + // (TODO Clarify meaning of unlockingBondsBalance.) uint64 unlockingBondsBalance = 6; } message BtcBalanceInfo { + // The BTC amount currently available to send to other addresses at the user's discretion, in satoshis. uint64 availableBalance = 1; + // The BTC amount currently reserved to cover open offers' security deposits, and BTC sellers' payout amounts, + // in satoshis. Reserved funds are not spendable, but are recoverable by users. When a user cancels an offer + // funds reserved for that offer are returned to the availableBalance. uint64 reservedBalance = 2; + // The sum of availableBalance + reservedBalance, in satoshis. uint64 totalAvailableBalance = 3; + // The BTC amount being locked to cover the security deposits and BTC seller's pending trade payouts. Locked + // funds are not recoverable until a trade is completed, when security deposits are returned to the availableBalance. uint64 lockedBalance = 4; } message AddressBalanceInfo { - string address = 1; - int64 balance = 2; - int64 numConfirmations = 3; - bool isAddressUnused = 4; + string address = 1; // The bitcoin wallet address. + int64 balance = 2; // The address' BTC balance in satoshis. + int64 numConfirmations = 3; // The number of confirmations for the most recent transaction referencing the output address. + bool isAddressUnused = 4; // Whether the bitcoin address has ever been used, or not. } service GetVersion { @@ -922,5 +953,5 @@ message GetVersionRequest { } message GetVersionReply { - string version = 1; + string version = 1; // The version of the Bisq software release. } From 9f013bd6c249575486035e2b88b56c820208e744 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Mon, 21 Feb 2022 08:00:31 -0300 Subject: [PATCH 03/14] Fix errors in comments --- proto/src/main/proto/grpc.proto | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index 4a5840d215e..0d0c995a92a 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -699,8 +699,8 @@ message TxFeeRateInfo { message TxInfo { string txId = 1; // The bitcoin transaction id. - uint64 inputSum = 2; // The sum of the bitcoin transactions input values in satoshis. - uint64 outputSum = 3; // The sum of the bitcoin transactions output values in satoshis. + uint64 inputSum = 2; // The sum of the bitcoin transaction's input values in satoshis. + uint64 outputSum = 3; // The sum of the bitcoin transaction's output values in satoshis. uint64 fee = 4; // The bitcoin transaction's miner fee in satoshis. int32 size = 5; // The bitcoin transaction's size in bytes. bool isPending = 6; // Whether the bitcoin transaction has been confirmed at least one time, or not. @@ -733,7 +733,7 @@ service Wallets { // which has been solved by the introduction of BSQ swap trades, which use a different, unused BSQ address for each trade. rpc VerifyBsqSentToAddress (VerifyBsqSentToAddressRequest) returns (VerifyBsqSentToAddressReply) { } - // Get the most recently available Bisq network's bitcoin miner transaction fee rate, or custom fee rate if set. + // Get the Bisq network's most recently available bitcoin miner transaction fee rate, or custom fee rate if set. rpc GetTxFeeRate (GetTxFeeRateRequest) returns (GetTxFeeRateReply) { } // Set the Bisq daemon's custom bitcoin miner transaction fee rate, in sats/byte.. @@ -745,12 +745,10 @@ service Wallets { // Get a bitcoin transaction summary. rpc GetTransaction (GetTransactionRequest) returns (GetTransactionReply) { } - // Get all bitcoin receiving address in the Bisq BTC wallet. + // Get all bitcoin receiving addresses in the Bisq BTC wallet. rpc GetFundingAddresses (GetFundingAddressesRequest) returns (GetFundingAddressesReply) { } - // Set the Bisq wallet's encryption password for a time period in seconds. An unlocked wallet will automatically - // lock itself after the timeout period has expired, or a LockWallet request has been made, whichever is first. - // An unlocked wallet's timeout setting can be overridden by subsequent SetWalletPassword calls. + // Set the Bisq wallet's encryption password. rpc SetWalletPassword (SetWalletPasswordRequest) returns (SetWalletPasswordReply) { } // Remove the encryption password from the Bisq wallet. @@ -759,7 +757,10 @@ service Wallets { // Lock an encrypted Bisq wallet before the UnlockWallet rpc method's timeout period has expired. rpc LockWallet (LockWalletRequest) returns (LockWalletReply) { } - // Unlock a Bisq encrypted wallet before calling wallet sensitive rpc methods: CreateOffer, TakeOffer, GetBalances, etc. + // Unlock a Bisq encrypted wallet before calling wallet sensitive rpc methods: CreateOffer, TakeOffer, GetBalances, + // etc., for a timeout period in seconds. An unlocked wallet will automatically lock itself after the timeout + // period has expired, or a LockWallet request has been made, whichever is first. An unlocked wallet's timeout + // setting can be overridden by subsequent SetWalletPassword calls. rpc UnlockWallet (UnlockWalletRequest) returns (UnlockWalletReply) { } } From 6e566603945a9c65690964bad8a0af2679e64c17 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Mon, 21 Feb 2022 08:09:42 -0300 Subject: [PATCH 04/14] Fix comment error --- proto/src/main/proto/grpc.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index 0d0c995a92a..4a1723f6814 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -760,7 +760,7 @@ service Wallets { // Unlock a Bisq encrypted wallet before calling wallet sensitive rpc methods: CreateOffer, TakeOffer, GetBalances, // etc., for a timeout period in seconds. An unlocked wallet will automatically lock itself after the timeout // period has expired, or a LockWallet request has been made, whichever is first. An unlocked wallet's timeout - // setting can be overridden by subsequent SetWalletPassword calls. + // setting can be overridden by subsequent UnlockWallet calls. rpc UnlockWallet (UnlockWalletRequest) returns (UnlockWalletReply) { } } From 464c5a81c99e288b0ae3dde3831a4276150df0e1 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Mon, 21 Feb 2022 08:13:13 -0300 Subject: [PATCH 05/14] Be consistent in use of apostrophe --- proto/src/main/proto/grpc.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index 4a1723f6814..1595202ac34 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -892,7 +892,7 @@ message LockWalletReply { message UnlockWalletRequest { string password = 1; // The Bisq wallet's encryption password. - uint64 timeout = 2; // The Bisq wallet unlock time period, in seconds. + uint64 timeout = 2; // The Bisq wallet's unlock time period, in seconds. } message UnlockWalletReply { From 5e754a25a131ddb2d6edc6258e07d2631c902d44 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Thu, 24 Feb 2022 08:28:36 -0300 Subject: [PATCH 06/14] Fix comment --- .../java/bisq/apitest/method/offer/CreateXMROffersTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apitest/src/test/java/bisq/apitest/method/offer/CreateXMROffersTest.java b/apitest/src/test/java/bisq/apitest/method/offer/CreateXMROffersTest.java index 64d46e279f9..cb9db33a145 100644 --- a/apitest/src/test/java/bisq/apitest/method/offer/CreateXMROffersTest.java +++ b/apitest/src/test/java/bisq/apitest/method/offer/CreateXMROffersTest.java @@ -64,7 +64,7 @@ public void testCreateFixedPriceBuy1BTCFor200KXMROffer() { XMR, 100_000_000L, 75_000_000L, - "0.005", // FIXED PRICE IN BTC (satoshis) FOR 1 XMR + "0.005", // FIXED PRICE IN BTC FOR 1 XMR defaultBuyerSecurityDepositPct.get(), alicesXmrAcct.getId(), MAKER_FEE_CURRENCY_CODE); From 66c04134fcffbc940138c0bc54841c03088a2ce5 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Fri, 25 Feb 2022 18:51:07 -0300 Subject: [PATCH 07/14] Check offer exists before trying to take it This was overlooked in tests, but client might use a bad offer-id param. --- .../bisq/daemon/grpc/GrpcTradesService.java | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/daemon/src/main/java/bisq/daemon/grpc/GrpcTradesService.java b/daemon/src/main/java/bisq/daemon/grpc/GrpcTradesService.java index 9331e154cef..904d406e04f 100644 --- a/daemon/src/main/java/bisq/daemon/grpc/GrpcTradesService.java +++ b/daemon/src/main/java/bisq/daemon/grpc/GrpcTradesService.java @@ -20,6 +20,7 @@ import bisq.core.api.CoreApi; import bisq.core.api.model.CanceledTradeInfo; import bisq.core.api.model.TradeInfo; +import bisq.core.offer.Offer; import bisq.core.offer.OpenOffer; import bisq.core.trade.model.TradeModel; import bisq.core.trade.model.bisq_v1.Trade; @@ -93,31 +94,37 @@ public void takeOffer(TakeOfferRequest req, responseObserver, exceptionHandler, log); - - if (coreApi.isBsqSwapOffer(req.getOfferId(), false)) { - coreApi.takeBsqSwapOffer(req.getOfferId(), - bsqSwapTrade -> { - var reply = buildTakeOfferReply(bsqSwapTrade); - responseObserver.onNext(reply); - responseObserver.onCompleted(); - }, - errorMessage -> { - if (!errorMessageHandler.isErrorHandled()) - errorMessageHandler.handleErrorMessage(errorMessage); - }); - } else { - coreApi.takeOffer(req.getOfferId(), - req.getPaymentAccountId(), - req.getTakerFeeCurrencyCode(), - trade -> { - var reply = buildTakeOfferReply(trade); - responseObserver.onNext(reply); - responseObserver.onCompleted(); - }, - errorMessage -> { - if (!errorMessageHandler.isErrorHandled()) - errorMessageHandler.handleErrorMessage(errorMessage); - }); + try { + // Make sure the offer exists before trying to take it. + Offer offer = coreApi.getOffer(req.getOfferId()); + + if (offer.isBsqSwapOffer()) { + coreApi.takeBsqSwapOffer(offer.getId(), + bsqSwapTrade -> { + var reply = buildTakeOfferReply(bsqSwapTrade); + responseObserver.onNext(reply); + responseObserver.onCompleted(); + }, + errorMessage -> { + if (!errorMessageHandler.isErrorHandled()) + errorMessageHandler.handleErrorMessage(errorMessage); + }); + } else { + coreApi.takeOffer(offer.getId(), + req.getPaymentAccountId(), + req.getTakerFeeCurrencyCode(), + trade -> { + var reply = buildTakeOfferReply(trade); + responseObserver.onNext(reply); + responseObserver.onCompleted(); + }, + errorMessage -> { + if (!errorMessageHandler.isErrorHandled()) + errorMessageHandler.handleErrorMessage(errorMessage); + }); + } + } catch (Throwable cause) { + exceptionHandler.handleException(log, cause, responseObserver); } } From c0631eb31fd3d189d520b2a9ccc23a2db61203e2 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Fri, 25 Feb 2022 20:51:55 -0300 Subject: [PATCH 08/14] Fix file/merge conflict --- proto/src/main/proto/grpc.proto | 2 -- 1 file changed, 2 deletions(-) diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index cbe6a4701ac..1595202ac34 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -172,7 +172,6 @@ message GetMyBsqSwapOffersReply { repeated OfferInfo bsqSwapOffers = 1; // The returned list of user's open BSQ swap offers. } -// TODO: Change some numeric fields to string to prevent loss of precision and/or ambiguity. message CreateBsqSwapOfferRequest { // The new BSQ swap offer's BUY (BTC) or SELL (BTC) direction. string direction = 1; @@ -188,7 +187,6 @@ message CreateBsqSwapOfferReply { OfferInfo bsqSwapOffer = 1; // The newly created BSQ swap offer. } -// TODO: Change some numeric fields to string to prevent loss of precision and/or ambiguity. message CreateOfferRequest { // The new offer's fiat or altcoin currency code. string currencyCode = 1; From ab8a3433c36b20b57aa7e15319b7e3f71e5e483b Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sat, 26 Feb 2022 14:27:52 -0300 Subject: [PATCH 09/14] Use a zero fixed-price if useMarketBasedPrice=true The CLI and apitest cases always pass "0", but java & python clients might pass an empty string. This change avoids number formatting & scaling problems when clients pass an empty string in the price parameter. --- core/src/main/java/bisq/core/api/CoreApi.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/bisq/core/api/CoreApi.java b/core/src/main/java/bisq/core/api/CoreApi.java index 1294d2820e5..073d3075dea 100644 --- a/core/src/main/java/bisq/core/api/CoreApi.java +++ b/core/src/main/java/bisq/core/api/CoreApi.java @@ -206,7 +206,7 @@ public void createAndPlaceOffer(String currencyCode, Consumer resultHandler) { coreOffersService.createAndPlaceOffer(currencyCode, directionAsString, - price, + useMarketBasedPrice ? "0" : price, useMarketBasedPrice, marketPriceMargin, amountAsLong, From fcd2bcd34f977140bcc1290a2ec86a0ffbcc18eb Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:13:21 -0300 Subject: [PATCH 10/14] Allow editoffer clients to pass empty string for price parameter The client may have passed an empty string for the price parameter, if only enabling or disabling the offer. If so, validate with new price = old price. --- core/src/main/java/bisq/core/api/EditOfferValidator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/bisq/core/api/EditOfferValidator.java b/core/src/main/java/bisq/core/api/EditOfferValidator.java index 977b7a738e7..f3b90e7f1eb 100644 --- a/core/src/main/java/bisq/core/api/EditOfferValidator.java +++ b/core/src/main/java/bisq/core/api/EditOfferValidator.java @@ -68,7 +68,12 @@ class EditOfferValidator { int newEnable, EditOfferRequest.EditType editType) { this.currentlyOpenOffer = currentlyOpenOffer; - this.newPrice = newPrice; + // The client may have passed an empty string for the price parameter + // if only enabling or disabling the offer. If so, validate with new + // price = old price. + this.newPrice = editType.equals(ACTIVATION_STATE_ONLY) + ? currentlyOpenOffer.getOffer().getPrice().toString() + : newPrice; // The client cannot determine what offer.isUseMarketBasedPrice should be // when editType = ACTIVATION_STATE_ONLY. Override newIsUseMarketBasedPrice // param for the ACTIVATION_STATE_ONLY case. From aa6f5305552647a9b6a0485c537de95eb8d1e1ed Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:26:24 -0300 Subject: [PATCH 11/14] Revert "Allow editoffer clients to pass empty string for price parameter" This reverts commit fcd2bcd34f977140bcc1290a2ec86a0ffbcc18eb. --- core/src/main/java/bisq/core/api/EditOfferValidator.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/core/src/main/java/bisq/core/api/EditOfferValidator.java b/core/src/main/java/bisq/core/api/EditOfferValidator.java index f3b90e7f1eb..977b7a738e7 100644 --- a/core/src/main/java/bisq/core/api/EditOfferValidator.java +++ b/core/src/main/java/bisq/core/api/EditOfferValidator.java @@ -68,12 +68,7 @@ class EditOfferValidator { int newEnable, EditOfferRequest.EditType editType) { this.currentlyOpenOffer = currentlyOpenOffer; - // The client may have passed an empty string for the price parameter - // if only enabling or disabling the offer. If so, validate with new - // price = old price. - this.newPrice = editType.equals(ACTIVATION_STATE_ONLY) - ? currentlyOpenOffer.getOffer().getPrice().toString() - : newPrice; + this.newPrice = newPrice; // The client cannot determine what offer.isUseMarketBasedPrice should be // when editType = ACTIVATION_STATE_ONLY. Override newIsUseMarketBasedPrice // param for the ACTIVATION_STATE_ONLY case. From b9040029916e8ff3f0c5e0051d5169f9303c490b Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sat, 26 Feb 2022 17:17:42 -0300 Subject: [PATCH 12/14] Avoid number formatting problems if clients pass empty (default) str params --- core/src/main/java/bisq/core/api/EditOfferValidator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/bisq/core/api/EditOfferValidator.java b/core/src/main/java/bisq/core/api/EditOfferValidator.java index 977b7a738e7..e6123e14bd8 100644 --- a/core/src/main/java/bisq/core/api/EditOfferValidator.java +++ b/core/src/main/java/bisq/core/api/EditOfferValidator.java @@ -68,7 +68,7 @@ class EditOfferValidator { int newEnable, EditOfferRequest.EditType editType) { this.currentlyOpenOffer = currentlyOpenOffer; - this.newPrice = newPrice; + this.newPrice = newPrice.isBlank() ? "0" : newPrice; // The client cannot determine what offer.isUseMarketBasedPrice should be // when editType = ACTIVATION_STATE_ONLY. Override newIsUseMarketBasedPrice // param for the ACTIVATION_STATE_ONLY case. @@ -78,12 +78,12 @@ class EditOfferValidator { ? currentlyOpenOffer.getOffer().isUseMarketBasedPrice() : newIsUseMarketBasedPrice; this.newMarketPriceMargin = newMarketPriceMargin; - this.newTriggerPrice = newTriggerPrice; + this.newTriggerPrice = newTriggerPrice.isBlank() ? "0" : newTriggerPrice; this.newEnable = newEnable; this.editType = editType; - this.isZeroEditedFixedPriceString = new BigDecimal(newPrice).doubleValue() == 0; - this.isZeroEditedTriggerPrice = new BigDecimal(newTriggerPrice).equals(ZERO); + this.isZeroEditedFixedPriceString = new BigDecimal(this.newPrice).doubleValue() == 0; + this.isZeroEditedTriggerPrice = new BigDecimal(this.newTriggerPrice).equals(ZERO); } EditOfferValidator validate() { From c20f2568d4d1e8ea859772c4233f1be8478d1759 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sat, 26 Feb 2022 17:43:17 -0300 Subject: [PATCH 13/14] Allow clients to pass empty string for minAmount param --- core/src/main/java/bisq/core/api/CoreOffersService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/bisq/core/api/CoreOffersService.java b/core/src/main/java/bisq/core/api/CoreOffersService.java index aacc59cc2bf..4fdd8495738 100644 --- a/core/src/main/java/bisq/core/api/CoreOffersService.java +++ b/core/src/main/java/bisq/core/api/CoreOffersService.java @@ -259,7 +259,7 @@ void createAndPlaceBsqSwapOffer(String directionAsString, String offerId = getRandomOfferId(); OfferDirection direction = OfferDirection.valueOf(directionAsString.toUpperCase()); Coin amount = Coin.valueOf(amountAsLong); - Coin minAmount = Coin.valueOf(minAmountAsLong); + Coin minAmount = minAmountAsLong == 0 ? amount : Coin.valueOf(minAmountAsLong); Price price = Price.valueOf(currencyCode, priceStringToLong(priceAsString, currencyCode)); openBsqSwapOfferService.requestNewOffer(offerId, direction, @@ -294,7 +294,7 @@ void createAndPlaceOffer(String currencyCode, OfferDirection direction = OfferDirection.valueOf(directionAsString.toUpperCase()); Price price = Price.valueOf(upperCaseCurrencyCode, priceStringToLong(priceAsString, upperCaseCurrencyCode)); Coin amount = Coin.valueOf(amountAsLong); - Coin minAmount = Coin.valueOf(minAmountAsLong); + Coin minAmount = minAmountAsLong == 0 ? amount : Coin.valueOf(minAmountAsLong); Coin useDefaultTxFee = Coin.ZERO; // Almost ready to call createOfferService.createAndGetOffer(), but first: From f14806ea1f377dae49bc27e116ec8bc6d5c4861a Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sat, 26 Feb 2022 17:43:17 -0300 Subject: [PATCH 14/14] Let minAmount param be optional --- core/src/main/java/bisq/core/api/CoreOffersService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/bisq/core/api/CoreOffersService.java b/core/src/main/java/bisq/core/api/CoreOffersService.java index aacc59cc2bf..4fdd8495738 100644 --- a/core/src/main/java/bisq/core/api/CoreOffersService.java +++ b/core/src/main/java/bisq/core/api/CoreOffersService.java @@ -259,7 +259,7 @@ void createAndPlaceBsqSwapOffer(String directionAsString, String offerId = getRandomOfferId(); OfferDirection direction = OfferDirection.valueOf(directionAsString.toUpperCase()); Coin amount = Coin.valueOf(amountAsLong); - Coin minAmount = Coin.valueOf(minAmountAsLong); + Coin minAmount = minAmountAsLong == 0 ? amount : Coin.valueOf(minAmountAsLong); Price price = Price.valueOf(currencyCode, priceStringToLong(priceAsString, currencyCode)); openBsqSwapOfferService.requestNewOffer(offerId, direction, @@ -294,7 +294,7 @@ void createAndPlaceOffer(String currencyCode, OfferDirection direction = OfferDirection.valueOf(directionAsString.toUpperCase()); Price price = Price.valueOf(upperCaseCurrencyCode, priceStringToLong(priceAsString, upperCaseCurrencyCode)); Coin amount = Coin.valueOf(amountAsLong); - Coin minAmount = Coin.valueOf(minAmountAsLong); + Coin minAmount = minAmountAsLong == 0 ? amount : Coin.valueOf(minAmountAsLong); Coin useDefaultTxFee = Coin.ZERO; // Almost ready to call createOfferService.createAndGetOffer(), but first: