lnrpc: ability to spend unconfirmed coins
This commit is contained in:
15 files changed
+1030
-764
No files matched your search
@@ -21,8 +21,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
defaultUtxoMinConf = 1
|
||||
userMsgFund = `PSBT funding initiated with peer %x.
|
||||
userMsgFund = `PSBT funding initiated with peer %x.
|
||||
Please create a PSBT that sends %v (%d satoshi) to the funding address %s.
|
||||
|
||||
Note: The whole process should be completed within 10 minutes, otherwise there
|
||||
@@ -43,7 +42,7 @@ Paste the funded PSBT here to continue the funding flow.
|
||||
Base64 encoded PSBT: `
|
||||
|
||||
userMsgSign = `
|
||||
PSBT verified by lnd, please continue the funding flow by signing the PSBT by
|
||||
PSBT verified by lnd, please continue the funding flow by signing the PSBT by
|
||||
all required parties/devices. Once the transaction is fully signed, paste it
|
||||
again here either in base64 PSBT or hex encoded raw wire TX format.
|
||||
|
||||
@@ -68,7 +67,7 @@ var openChannelCommand = cli.Command{
|
||||
amount to the remote node as part of the channel opening. Once the channel is open,
|
||||
a channelPoint (txid:vout) of the funding output is returned.
|
||||
|
||||
If the remote peer supports the option upfront shutdown feature bit (query
|
||||
If the remote peer supports the option upfront shutdown feature bit (query
|
||||
listpeers to see their supported feature bits), an address to enforce
|
||||
payout of funds on cooperative close can optionally be provided. Note that
|
||||
if you set this value, you will not be able to cooperatively close out to
|
||||
|
||||
+35
-11
@@ -35,6 +35,10 @@ import (
|
||||
|
||||
const defaultRecoveryWindow int32 = 2500
|
||||
|
||||
const (
|
||||
defaultUtxoMinConf = 1
|
||||
)
|
||||
|
||||
func printJSON(resp interface{}) {
|
||||
b, err := json.Marshal(resp)
|
||||
if err != nil {
|
||||
@@ -238,6 +242,13 @@ var sendCoinsCommand = cli.Command{
|
||||
"sat/byte that should be used when crafting " +
|
||||
"the transaction",
|
||||
},
|
||||
cli.Uint64Flag{
|
||||
Name: "min_confs",
|
||||
Usage: "(optional) the minimum number of confirmations " +
|
||||
"each one of your outputs used for the transaction " +
|
||||
"must satisfy",
|
||||
Value: defaultUtxoMinConf,
|
||||
},
|
||||
txLabelFlag,
|
||||
},
|
||||
Action: actionDecorator(sendCoins),
|
||||
@@ -292,13 +303,16 @@ func sendCoins(ctx *cli.Context) error {
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
minConfs := int32(ctx.Uint64("min_confs"))
|
||||
req := &lnrpc.SendCoinsRequest{
|
||||
Addr: addr,
|
||||
Amount: amt,
|
||||
TargetConf: int32(ctx.Int64("conf_target")),
|
||||
SatPerByte: ctx.Int64("sat_per_byte"),
|
||||
SendAll: ctx.Bool("sweepall"),
|
||||
Label: ctx.String(txLabelFlag.Name),
|
||||
Addr: addr,
|
||||
Amount: amt,
|
||||
TargetConf: int32(ctx.Int64("conf_target")),
|
||||
SatPerByte: ctx.Int64("sat_per_byte"),
|
||||
SendAll: ctx.Bool("sweepall"),
|
||||
Label: ctx.String(txLabelFlag.Name),
|
||||
MinConfs: minConfs,
|
||||
SpendUnconfirmed: minConfs == 0,
|
||||
}
|
||||
txid, err := client.SendCoins(ctxb, req)
|
||||
if err != nil {
|
||||
@@ -454,6 +468,13 @@ var sendManyCommand = cli.Command{
|
||||
Usage: "(optional) a manual fee expressed in sat/byte that should be " +
|
||||
"used when crafting the transaction",
|
||||
},
|
||||
cli.Uint64Flag{
|
||||
Name: "min_confs",
|
||||
Usage: "(optional) the minimum number of confirmations " +
|
||||
"each one of your outputs used for the transaction " +
|
||||
"must satisfy",
|
||||
Value: defaultUtxoMinConf,
|
||||
},
|
||||
txLabelFlag,
|
||||
},
|
||||
Action: actionDecorator(sendMany),
|
||||
@@ -476,11 +497,14 @@ func sendMany(ctx *cli.Context) error {
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
minConfs := int32(ctx.Uint64("min_confs"))
|
||||
txid, err := client.SendMany(ctxb, &lnrpc.SendManyRequest{
|
||||
AddrToAmount: amountToAddr,
|
||||
TargetConf: int32(ctx.Int64("conf_target")),
|
||||
SatPerByte: ctx.Int64("sat_per_byte"),
|
||||
Label: ctx.String(txLabelFlag.Name),
|
||||
AddrToAmount: amountToAddr,
|
||||
TargetConf: int32(ctx.Int64("conf_target")),
|
||||
SatPerByte: ctx.Int64("sat_per_byte"),
|
||||
Label: ctx.String(txLabelFlag.Name),
|
||||
MinConfs: minConfs,
|
||||
SpendUnconfirmed: minConfs == 0,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1814,7 +1838,7 @@ var listChainTxnsCommand = cli.Command{
|
||||
To get all transactions until the chain tip, including unconfirmed
|
||||
transactions (identifiable with BlockHeight=0), set end_height to -1.
|
||||
By default, this call will get all transactions our wallet was involved
|
||||
in, including unconfirmed transactions.
|
||||
in, including unconfirmed transactions.
|
||||
`,
|
||||
Action: actionDecorator(listChainTxns),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user