public static async Task <StellarOperationResult> AcceptPackageAsRecipient(string escrowPubkey, string paymentTransaction, string location) { //var courierBalance = await App.Locator.ServiceClient.Balance(App.Locator.Profile.Pubkey); var signed = await StellarHelper.SignTransaction(App.Locator.Profile.KeyPair, paymentTransaction); //sign the payment transaction var submitResult = await App.Locator.BridgeServiceClient.SubmitTransaction(signed); if (submitResult != null) { var result = await App.Locator.RouteServiceClient.AcceptPackage(escrowPubkey, location); //accept the package if (result != null) { return(StellarOperationResult.Success); } else { return(StellarOperationResult.FailAcceptPackage); } } else { return(StellarOperationResult.FailAcceptPackage); } }
public static async Task <StellarOperationResult> AcceptPackageAsCourier(string escrowPubkey, long collateral, string paymentTransaction, string location) { var courierBalance = await App.Locator.BridgeServiceClient.Balance(App.Locator.Profile.Pubkey); if (courierBalance == null || courierBalance.Account.BalanceBUL < collateral) { return(StellarOperationResult.LowBULsCourier); } var trans = await App.Locator.BridgeServiceClient.PrepareSendBuls(App.Locator.Profile.Pubkey, escrowPubkey, (collateral / 10000000.0f)); if (trans != null) { var signed = await StellarHelper.SignTransaction(App.Locator.Profile.KeyPair, trans.Transaction); var paymentResult = await App.Locator.BridgeServiceClient.SubmitTransaction(signed); if (paymentResult != null) { var acceptResult = await App.Locator.RouteServiceClient.AcceptPackage(escrowPubkey, location); if (acceptResult != null) { //var newCourierBalance = await App.Locator.ServiceClient.Balance(App.Locator.Profile.Pubkey);//TODO remove balance check //if (newCourierBalance.BalanceBUL == courierBalance.BalanceBUL - collateral) { App.Locator.Profile.AddTransaction(escrowPubkey, paymentTransaction); return(StellarOperationResult.Success); //} //return StellarOperationResult.IncositentBalance; } else { return(StellarOperationResult.FailAcceptPackage); } } else { return(StellarOperationResult.FailSendCollateral); } } else { return(StellarOperationResult.FailSendCollateral); } }
private async void SendClicked(object sender, EventArgs e) { if (EntryRecepient.IsBusy) { return; } else if (recipient.Length == 0) { EntryRecepient.FocusField(); } else if (IsValid()) { Unfocus(); App.ShowLoading(true); try { double amount = double.Parse(EntryAmount.Text); var trans = await App.Locator.BridgeServiceClient.PrepareSendBuls(App.Locator.Profile.Pubkey, recipient, amount); if (trans != null) { var signed = await StellarHelper.SignTransaction(App.Locator.Profile.KeyPair, trans.Transaction); var result = await App.Locator.BridgeServiceClient.SubmitTransaction(signed); if (result != null) { await ViewModel.Load(); SundBULSMainStackView.IsVisible = false; SendBULSSuccessView.IsVisible = true; } } } catch (Exception ex) { EventHandler handler = (se, ee) => { if (ee != null) { ShowEntry(PurchaseBULEntryViews); if (PickerBULCurrency.SelectedItem == null) { PickerBULCurrency.Focus(); } } else { EntryAmount.Focus(); } }; if (ex.Message == AppResources.InsufficientBULs) { ShowErrorMessage(AppResources.PurchaseBULs, false, handler, AppResources.Purchase); } else { ShowErrorMessage(ex.Message, false, handler); } } App.ShowLoading(false); EnableDisableButton(); } }