diff options
author | Florian Dold <florian@dold.me> | 2023-01-06 11:08:45 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-01-06 11:08:45 +0100 |
commit | c2c35925bb953bf07e32c005dbe312d220b45749 (patch) | |
tree | 2fcb5eb7ad737f6cba796a3f1bbc66f763e970a7 /packages/taler-util/src/wallet-types.ts | |
parent | 80639429a23c34bdfbb5f3853caf721b49fd6beb (diff) | |
download | wallet-core-c2c35925bb953bf07e32c005dbe312d220b45749.tar.xz |
wallet-core: allow failure result in peer payment coin selection
Diffstat (limited to 'packages/taler-util/src/wallet-types.ts')
-rw-r--r-- | packages/taler-util/src/wallet-types.ts | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index b63e043f5..3a1176021 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -419,7 +419,10 @@ export const codecForPreparePayResultInsufficientBalance = "status", codecForConstString(PreparePayResultType.InsufficientBalance), ) - .property("balanceDetails", codecForPayMerchantInsufficientBalanceDetails()) + .property( + "balanceDetails", + codecForPayMerchantInsufficientBalanceDetails(), + ) .build("PreparePayResultInsufficientBalance"); export const codecForPreparePayResultAlreadyConfirmed = @@ -2084,7 +2087,6 @@ export interface InitiatePeerPullPaymentResponse { transactionId: string; } - /** * Detailed reason for why the wallet's balance is insufficient. */ @@ -2124,23 +2126,58 @@ export interface PayMerchantInsufficientBalanceDetails { * (i.e. balanceMechantWireable >= amountRequested), * this field contains an estimate of the amount that would additionally * be required to cover the fees. - * + * * It is not possible to give an exact value here, since it depends * on the coin selection for the amount that would be additionally withdrawn. */ feeGapEstimate: AmountString; } -const codecForPayMerchantInsufficientBalanceDetails = -(): Codec<PayMerchantInsufficientBalanceDetails> => - buildCodecForObject<PayMerchantInsufficientBalanceDetails>() - .property("amountRequested", codecForAmountString()) - .property("balanceAgeAcceptable", codecForAmountString()) - .property("balanceAvailable", codecForAmountString()) - .property("balanceMaterial", codecForAmountString()) - .property("balanceMerchantAcceptable", codecForAmountString()) - .property("balanceMerchantDepositable", codecForAmountString()) - .property("feeGapEstimate", codecForAmountString()) - .build("PayMerchantInsufficientBalanceDetails"); +export const codecForPayMerchantInsufficientBalanceDetails = + (): Codec<PayMerchantInsufficientBalanceDetails> => + buildCodecForObject<PayMerchantInsufficientBalanceDetails>() + .property("amountRequested", codecForAmountString()) + .property("balanceAgeAcceptable", codecForAmountString()) + .property("balanceAvailable", codecForAmountString()) + .property("balanceMaterial", codecForAmountString()) + .property("balanceMerchantAcceptable", codecForAmountString()) + .property("balanceMerchantDepositable", codecForAmountString()) + .property("feeGapEstimate", codecForAmountString()) + .build("PayMerchantInsufficientBalanceDetails"); + +/** + * Detailed reason for why the wallet's balance is insufficient. + */ +export interface PayPeerInsufficientBalanceDetails { + /** + * Amount requested by the merchant. + */ + amountRequested: AmountString; + + /** + * Balance of type "available" (see balance.ts for definition). + */ + balanceAvailable: AmountString; + + /** + * Balance of type "material" (see balance.ts for definition). + */ + balanceMaterial: AmountString; + /** + * Acceptable balance based on restrictions on which + * exchange can be used. + */ + balanceExchangeAcceptable: AmountString + /** + * If the payment would succeed without fees + * (i.e. balanceExchangeAcceptable >= amountRequested), + * this field contains an estimate of the amount that would additionally + * be required to cover the fees. + * + * It is not possible to give an exact value here, since it depends + * on the coin selection for the amount that would be additionally withdrawn. + */ + feeGapEstimate: AmountString; +} |