mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-30 16:10:01 +01:00
cmd/lncli: add new option for easy AMP invoice re-use
In this commit, we add a new option (`--amp-reuse`) that allows for easy AMP invoice re-use when using either the `sendpayment` command.
This commit is contained in:
@@ -93,6 +93,12 @@ var (
|
|||||||
Usage: "if set to true, then AMP will be used to complete the " +
|
Usage: "if set to true, then AMP will be used to complete the " +
|
||||||
"payment",
|
"payment",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ampReuseFlag = cli.BoolFlag{
|
||||||
|
Name: "amp-reuse",
|
||||||
|
Usage: "if set to true, then a random payment address will " +
|
||||||
|
"be generated to enable re-use of an AMP invoice",
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// paymentFlags returns common flags for sendpayment and payinvoice.
|
// paymentFlags returns common flags for sendpayment and payinvoice.
|
||||||
@@ -138,6 +144,7 @@ func paymentFlags() []cli.Flag {
|
|||||||
},
|
},
|
||||||
dataFlag, inflightUpdatesFlag, maxPartsFlag, jsonFlag,
|
dataFlag, inflightUpdatesFlag, maxPartsFlag, jsonFlag,
|
||||||
maxShardSizeSatFlag, maxShardSizeMsatFlag, ampFlag,
|
maxShardSizeSatFlag, maxShardSizeMsatFlag, ampFlag,
|
||||||
|
ampReuseFlag,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,6 +250,16 @@ func parsePayAddr(ctx *cli.Context) ([]byte, error) {
|
|||||||
switch {
|
switch {
|
||||||
case ctx.IsSet("pay_addr"):
|
case ctx.IsSet("pay_addr"):
|
||||||
payAddr, err = hex.DecodeString(ctx.String("pay_addr"))
|
payAddr, err = hex.DecodeString(ctx.String("pay_addr"))
|
||||||
|
|
||||||
|
case ctx.IsSet(ampReuseFlag.Name):
|
||||||
|
var addrBytes [32]byte
|
||||||
|
if _, err := rand.Read(addrBytes[:]); err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to generate pay "+
|
||||||
|
"addr: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
payAddr = addrBytes[:]
|
||||||
|
|
||||||
case ctx.Args().Present():
|
case ctx.Args().Present():
|
||||||
payAddr, err = hex.DecodeString(ctx.Args().First())
|
payAddr, err = hex.DecodeString(ctx.Args().First())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user