Beispiel #1
0
        public async Task <IActionResult> WalletPSBTCombine([ModelBinder(typeof(WalletIdModelBinder))]
                                                            WalletId walletId, WalletPSBTCombineViewModel vm)
        {
            var network = NetworkProvider.GetNetwork <BTCPayNetwork>(walletId.CryptoCode);
            var psbt    = await vm.GetPSBT(network.NBitcoinNetwork);

            if (psbt == null)
            {
                ModelState.AddModelError(nameof(vm.PSBT), "Invalid PSBT");
                return(View(vm));
            }
            var sourcePSBT = vm.GetSourcePSBT(network.NBitcoinNetwork);

            if (sourcePSBT == null)
            {
                ModelState.AddModelError(nameof(vm.OtherPSBT), "Invalid PSBT");
                return(View(vm));
            }
            sourcePSBT = sourcePSBT.Combine(psbt);
            TempData[WellKnownTempData.SuccessMessage] = "PSBT Successfully combined!";
            return(RedirectToWalletPSBT(new WalletPSBTViewModel()
            {
                PSBT = sourcePSBT.ToBase64()
            }));
        }
        public async Task <IActionResult> WalletPSBTCombine([ModelBinder(typeof(WalletIdModelBinder))]
                                                            WalletId walletId, WalletPSBTCombineViewModel vm)
        {
            var network = NetworkProvider.GetNetwork(walletId.CryptoCode);
            var psbt    = await vm.GetPSBT(network.NBitcoinNetwork);

            if (psbt == null)
            {
                ModelState.AddModelError(nameof(vm.PSBT), "Invalid PSBT");
                return(View(vm));
            }
            var sourcePSBT = vm.GetSourcePSBT(network.NBitcoinNetwork);

            if (sourcePSBT == null)
            {
                ModelState.AddModelError(nameof(vm.OtherPSBT), "Invalid PSBT");
                return(View(vm));
            }
            sourcePSBT    = sourcePSBT.Combine(psbt);
            StatusMessage = "PSBT Successfully combined!";
            return(ViewPSBT(sourcePSBT));
        }