forked from bisq-network/bisq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change was prompted by the recent changes in the main branch to allow a tx memo field to be set from the UI and API. This and the prior PR address the API's need to be able to fetch a tx (with a memo). The API can now get a completed trade's withdrawal txid and pass it as a gettransaction parameter. See previous PR "Append nullable withdrawalTxId field to Trade". bisq-network#4937 A summary of changes by file: grpc.proto - Added withdrawalTxId field to existing TradeInfo proto & wrapper. - Reordered fields in TradeInfo proto. - Added new fields to be displayed by TxInfo proto in CLI. - Fixed typo: unsetTxFeeRatePreference -> UnsetTxFeeRatePreference. - Added new GetTransaction rpc. GrpcWalletsService - Added new getTransaction gRPC boilerplate. CoreWalletsService - Added new getTransaction implementation. TxInfo - Added the new fields for displaying a tx summary from CLI. This is not intended to be more than a brief summary; a block explorer or bitcoin-core client should be used to see the complete definition. TradeInfo - Added the new withdrawalTxId field defined in grpc.proto. CliMain - Added new 'case gettransaction'. TransactionFormat - Formats a TxInfo sent from the server to CLI. ColumnHeaderConstants - Added console headers used by TransactionFormat. TradeFormat - Displays a completed trade's WithdrawalTxId if present. Apitest - Adjusted affected tests: assert tx memo is persisted and test gettransaction.
- Loading branch information
Showing
15 changed files
with
341 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.cli; | ||
|
||
import bisq.proto.grpc.TxInfo; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
|
||
import static bisq.cli.ColumnHeaderConstants.*; | ||
import static bisq.cli.CurrencyFormat.formatSatoshis; | ||
import static com.google.common.base.Strings.padEnd; | ||
|
||
@VisibleForTesting | ||
public class TransactionFormat { | ||
|
||
public static String format(TxInfo txInfo) { | ||
String headerLine = padEnd(COL_HEADER_TX_ID, txInfo.getTxId().length(), ' ') + COL_HEADER_DELIMITER | ||
+ COL_HEADER_TX_IS_CONFIRMED + COL_HEADER_DELIMITER | ||
+ COL_HEADER_TX_INPUT_SUM + COL_HEADER_DELIMITER | ||
+ COL_HEADER_TX_OUTPUT_SUM + COL_HEADER_DELIMITER | ||
+ COL_HEADER_TX_FEE + COL_HEADER_DELIMITER | ||
+ COL_HEADER_TX_SIZE + COL_HEADER_DELIMITER | ||
+ (txInfo.getMemo().isEmpty() ? "" : COL_HEADER_TX_MEMO + COL_HEADER_DELIMITER) | ||
+ "\n"; | ||
|
||
String colDataFormat = "%-" + txInfo.getTxId().length() + "s" | ||
+ " %" + COL_HEADER_TX_IS_CONFIRMED.length() + "s" | ||
+ " %" + COL_HEADER_TX_INPUT_SUM.length() + "s" | ||
+ " %" + COL_HEADER_TX_OUTPUT_SUM.length() + "s" | ||
+ " %" + COL_HEADER_TX_FEE.length() + "s" | ||
+ " %" + COL_HEADER_TX_SIZE.length() + "s" | ||
+ " %s"; | ||
|
||
return headerLine | ||
+ String.format(colDataFormat, | ||
txInfo.getTxId(), | ||
txInfo.getIsPending() ? "NO" : "YES", // pending=true means not confirmed | ||
formatSatoshis(txInfo.getInputSum()), | ||
formatSatoshis(txInfo.getOutputSum()), | ||
formatSatoshis(txInfo.getFee()), | ||
txInfo.getSize(), | ||
txInfo.getMemo().isEmpty() ? "" : txInfo.getMemo()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.