Skip to content

Commit

Permalink
- added error message for insuficient funds when attempting to accept…
Browse files Browse the repository at this point in the history
… a payment request

- fixed payment request details not working on Windows
- fixed denied payment request status bubble not updating in active chat
  • Loading branch information
firestorm40 committed Sep 16, 2024
1 parent fdc09aa commit d9467b4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Spixi/Network/StreamProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ public static void handleRequestFundsResponse(byte[] id, Address sender_wallet,

if (friend.chat_page != null)
{
byte[] b_tx_id = Transaction.txIdLegacyToV8(tx_id);
byte[]? b_tx_id = !string.IsNullOrEmpty(tx_id) ? Transaction.txIdLegacyToV8(tx_id) : null;
friend.chat_page.updateRequestFundsStatus(msg_id, b_tx_id, status);
}
}
Expand Down
9 changes: 8 additions & 1 deletion Spixi/Pages/Chat/SingleChatPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,13 @@ public void onConfirmPaymentRequest(FriendMessage msg, string amount)
// TODO: extract the date from the corresponding message
DateTime dt = DateTime.Now;
string date_text = String.Format("{0:t}", dt);

if (homePage != null)
{
homePage.onConfirmPaymentRequest(msg, friend, amount, date_text);
return;
}

Navigation.PushAsync(new WalletContactRequestPage(msg, friend, amount, date_text), Config.defaultXamarinAnimations);
}

Expand Down Expand Up @@ -1311,7 +1318,7 @@ public void updateTransactionStatus(string txid, bool verified)
Utils.sendUiCommand(this, "updateTransactionStatus", txid, status, status_icon);
}

public void updateRequestFundsStatus(byte[] msg_id, byte[] txid, string status)
public void updateRequestFundsStatus(byte[] msg_id, byte[]? txid, string status)
{
string status_icon = "fa-clock";
bool enableView = true;
Expand Down
5 changes: 5 additions & 0 deletions Spixi/Pages/Home/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ public void onContactDetails(Friend friend)
Navigation.PushAsync(new ContactDetails(friend, true), Config.defaultXamarinAnimations);
}

public void onConfirmPaymentRequest(FriendMessage msg, Friend friend, string amount, string date_text)
{
Navigation.PushAsync(new WalletContactRequestPage(msg, friend, amount, date_text), Config.defaultXamarinAnimations);
}

public async void quickScan()
{
var scanPage = new ScanPage();
Expand Down
22 changes: 19 additions & 3 deletions Spixi/Pages/Wallet/WalletContactRequestPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,31 @@ private void onDecline()

private void onSend()
{
IxiNumber fee = ConsensusConfig.forceTransactionPrice;
IxiNumber _amount = amount;

if (_amount < (long)0)
{
displaySpixiAlert(SpixiLocalization._SL("wallet-error-amount-title"), SpixiLocalization._SL("wallet-error-amount-text"), SpixiLocalization._SL("global-dialog-ok"));
return;
}

if (_amount + fee > Node.balance.balance)
{
string alert_body = String.Format(SpixiLocalization._SL("wallet-error-balance-text"), _amount + fee, Node.balance.balance);
displaySpixiAlert(SpixiLocalization._SL("wallet-error-balance-title"), alert_body, SpixiLocalization._SL("global-dialog-ok"));
return;
}


string msg_id = Crypto.hashToString(requestMsg.id);

// send tx details to the request
// Send tx details to the request
if (!requestMsg.message.StartsWith(":"))
{
// Create an ixian transaction and send it to the dlt network
Address to = friend.walletAddress;

IxiNumber fee = ConsensusConfig.forceTransactionPrice;

Address from = IxianHandler.getWalletStorage().getPrimaryAddress();
Address pubKey = new Address(IxianHandler.getWalletStorage().getPrimaryPublicKey());

Expand Down

0 comments on commit d9467b4

Please sign in to comment.