@@ -2186,6 +2186,34 @@ static struct command_result *check_offer_payable(struct command *cmd,
21862186 return NULL ;
21872187}
21882188
2189+ static struct command_result *
2190+ check_offer_sendamount_payable (struct command * cmd , const char * offerstr )
2191+ {
2192+ const char * err ;
2193+ struct tlv_offer * b12offer =
2194+ offer_decode (tmpctx , offerstr , strlen (offerstr ),
2195+ plugin_feature_set (cmd -> plugin ), chainparams , & err );
2196+ /* Is it a valid offer? */
2197+ if (!b12offer )
2198+ return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
2199+ "Invalid bolt12 offer: %s" , err );
2200+ /* FIXME: add currency support */
2201+ if (b12offer -> offer_currency )
2202+ return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
2203+ "Cannot pay offer in different currency %s" ,
2204+ b12offer -> offer_currency );
2205+ /* Can only be applied to *any amount* offers. */
2206+ if (b12offer -> offer_amount ) {
2207+ return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
2208+ "Offer does not allow any amount." );
2209+ }
2210+ /* Not recurrence, one time only. */
2211+ if (offer_recurrence (b12offer ))
2212+ return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
2213+ "Cannot sendamount recurring offers" );
2214+ return NULL ;
2215+ }
2216+
21892217struct xpay_params {
21902218 struct amount_msat * msat , * maxfee , * partial , * includefees_msat ;
21912219 const char * * layers ;
@@ -2258,7 +2286,11 @@ bip353_fetched(struct command *cmd,
22582286 json_tok_full (buf , result ));
22592287 offerstr = json_strdup (tmpctx , buf , offertok );
22602288
2261- ret = check_offer_payable (cmd , offerstr , xparams -> msat );
2289+ if (xparams -> includefees_msat )
2290+ ret = check_offer_sendamount_payable (cmd , offerstr );
2291+ else
2292+ ret = check_offer_payable (cmd , offerstr , xparams -> msat );
2293+
22622294 if (ret )
22632295 return ret ;
22642296
0 commit comments