24
24
#include " wallet/transactions/swaps/swap_tx_description.h"
25
25
#endif // BEAM_ATOMIC_SWAP_SUPPORT
26
26
#include < regex>
27
+ #include < string_view>
27
28
28
29
namespace beam ::wallet {
29
30
namespace {
@@ -145,6 +146,10 @@ void GetStatusResponseJson(const TxDescription& tx,
145
146
};
146
147
statusInterpreter = std::make_unique<AssetTxStatusInterpreter>(tx);
147
148
}
149
+ else if (tx.m_txType == TxType::PushTransaction)
150
+ {
151
+ statusInterpreter = std::make_unique<MaxPrivacyTxStatusInterpreter>(tx);
152
+ }
148
153
else if (tx.m_txType == TxType::AtomicSwap)
149
154
{
150
155
#ifdef BEAM_ATOMIC_SWAP_SUPPORT
@@ -156,8 +161,8 @@ void GetStatusResponseJson(const TxDescription& tx,
156
161
{" txId" , TxIDToString (tx.m_txId )},
157
162
{" status" , tx.m_status },
158
163
{" status_string" , statusInterpreter ? statusInterpreter->getStatus () : " unknown" },
159
- {" sender" , std::to_string ( tx.m_sender ? tx. m_myId : tx. m_peerId )},
160
- {" receiver" , std::to_string ( tx.m_sender ? tx. m_peerId : tx. m_myId )},
164
+ {" sender" , tx.getAddressFrom ( )},
165
+ {" receiver" , tx.getAddressTo ( )},
161
166
{" value" , tx.m_amount },
162
167
{" comment" , std::string{ tx.m_message .begin (), tx.m_message .end () }},
163
168
{" create_time" , tx.m_createTime },
@@ -849,7 +854,37 @@ OfferInput collectOfferInput(const JsonRpcId& id, const json& params)
849
854
void WalletApi::onCreateAddressMessage (const JsonRpcId& id, const json& params)
850
855
{
851
856
CreateAddress createAddress;
857
+
852
858
FillAddressData (id, params, createAddress);
859
+
860
+ auto it = params.find (" type" );
861
+ if (it != params.end ())
862
+ {
863
+ static constexpr std::array<std::pair<std::string_view, TxAddressType>, 4 > types =
864
+ {
865
+ {
866
+ {" regular" , TxAddressType::Regular},
867
+ {" offline" , TxAddressType::Offline},
868
+ {" max_privacy" , TxAddressType::MaxPrivacy},
869
+ {" public_offline" , TxAddressType::PublicOffline}
870
+ }
871
+ };
872
+ auto t = std::find_if (types.begin (), types.end (), [&](const auto & p) { return p.first == it->get <std::string>(); });
873
+ if (t != types.end ())
874
+ {
875
+ createAddress.type = t->second ;
876
+ }
877
+ }
878
+ it = params.find (" new_style_regular" );
879
+ if (it != params.end ())
880
+ {
881
+ createAddress.newStyleRegular = it->get <bool >();
882
+ }
883
+ it = params.find (" offline_payments" );
884
+ if (it != params.end ())
885
+ {
886
+ createAddress.offlinePayments = it->get <uint32_t >();
887
+ }
853
888
getHandler ().onMessage (id, createAddress);
854
889
}
855
890
@@ -930,21 +965,18 @@ OfferInput collectOfferInput(const JsonRpcId& id, const json& params)
930
965
auto txParams = ParseParameters (addressOrToken);
931
966
if (!txParams)
932
967
{
933
- throw jsonrpc_exception{ ApiError::InvalidAddress , " Invalid receiver address or token ." , id };
968
+ throw jsonrpc_exception{ ApiError::InvalidAddress , " Invalid receiver address." , id };
934
969
}
935
- send.txParameters = *txParams;
936
-
937
- if (auto peerID = send. txParameters . GetParameter <WalletID>(TxParameterID::PeerID); peerID)
970
+ send.txParameters = std::move ( *txParams) ;
971
+ auto peerID = send. txParameters . GetParameter <WalletID>(beam::wallet::TxParameterID::PeerID);
972
+ if (peerID)
938
973
{
939
974
send.address = *peerID;
940
- if (std::to_string (*peerID) != addressOrToken)
941
- {
942
- send.txParameters .SetParameter (beam::wallet::TxParameterID::OriginalToken, addressOrToken);
943
- }
944
975
}
945
- else
976
+
977
+ if (!peerID || std::to_string (*peerID) != addressOrToken)
946
978
{
947
- throw jsonrpc_exception{ ApiError::InvalidAddress , " Invalid receiver address. " , id } ;
979
+ send. txParameters . SetParameter (beam::wallet::TxParameterID::OriginalToken, addressOrToken) ;
948
980
}
949
981
950
982
if (existsJsonParam (params, " from" ))
@@ -1487,7 +1519,7 @@ OfferInput collectOfferInput(const JsonRpcId& id, const json& params)
1487
1519
{
1488
1520
{JsonRpcHrd, JsonRpcVerHrd},
1489
1521
{" id" , id},
1490
- {" result" , std::to_string ( res.address ) }
1522
+ {" result" , res.address }
1491
1523
};
1492
1524
}
1493
1525
@@ -1760,7 +1792,8 @@ OfferInput collectOfferInput(const JsonRpcId& id, const json& params)
1760
1792
resItem.tx ,
1761
1793
item,
1762
1794
resItem.txHeight ,
1763
- resItem.systemHeight );
1795
+ resItem.systemHeight ,
1796
+ true );
1764
1797
msg[" result" ].push_back (item);
1765
1798
}
1766
1799
}
0 commit comments