@@ -8,9 +8,11 @@ import (
8
8
"strconv"
9
9
"strings"
10
10
11
+ "github.com/btcsuite/btcd/wire"
11
12
taprootassets "github.com/lightninglabs/taproot-assets"
12
13
"github.com/lightninglabs/taproot-assets/tapcfg"
13
14
"github.com/lightninglabs/taproot-assets/taprpc"
15
+ wrpc "github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc"
14
16
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
15
17
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
16
18
"github.com/urfave/cli"
@@ -38,9 +40,28 @@ func parseScriptKeyType(c *cli.Context) (*taprpc.ScriptKeyTypeQuery, error) {
38
40
AllTypes : true ,
39
41
},
40
42
}
43
+ bip86ScriptKeysQuery := & taprpc.ScriptKeyTypeQuery {
44
+ Type : & taprpc.ScriptKeyTypeQuery_ExplicitType {
45
+ ExplicitType : taprpc .ScriptKeyType_SCRIPT_KEY_BIP86 ,
46
+ },
47
+ }
41
48
42
- if ! c .IsSet (scriptKeyTypeName ) || c .String (scriptKeyTypeName ) == "" {
49
+ // The default value if no script key type is set is aligned with the
50
+ // default value of the RPC interface, which is BIP-86 script keys.
51
+ switch {
52
+ // Both flags are set, which is not allowed.
53
+ case c .IsSet (scriptKeyTypeName ) && c .IsSet (scriptKeyTypeAll ):
54
+ return nil , fmt .Errorf ("cannot set both '%s' and '%s'" ,
55
+ scriptKeyTypeName , scriptKeyTypeAll )
56
+
57
+ // The "all script key types" flag is set, so we return a query
58
+ // that requests all script key types.
59
+ case c .Bool (scriptKeyTypeAll ):
43
60
return allScriptKeysQuery , nil
61
+
62
+ // No flag is set, use the default value of BIP-86 script keys.
63
+ case ! c .IsSet (scriptKeyTypeName ) || c .String (scriptKeyTypeName ) == "" :
64
+ return bip86ScriptKeysQuery , nil
44
65
}
45
66
46
67
scriptKeyType , ok := scriptKeyTypeMap [c .String (scriptKeyTypeName )]
@@ -73,11 +94,12 @@ var assetsCommands = []cli.Command{
73
94
listBurnsCommand ,
74
95
listTransfersCommand ,
75
96
fetchMetaCommand ,
97
+ removeUtxoLeaseCommand ,
76
98
},
77
99
},
78
100
}
79
101
80
- var (
102
+ const (
81
103
assetTypeName = "type"
82
104
assetTagName = "name"
83
105
assetSupplyName = "supply"
@@ -105,6 +127,7 @@ var (
105
127
assetAmountName = "amount"
106
128
burnOverrideConfirmationName = "override_confirmation_destroy_assets"
107
129
scriptKeyTypeName = "script_key_type"
130
+ scriptKeyTypeAll = "all_script_key_types"
108
131
)
109
132
110
133
var mintAssetCommand = cli.Command {
@@ -714,6 +737,13 @@ var listAssetsCommand = cli.Command{
714
737
Usage : "filter assets by the type of script key they " +
715
738
"use; possible values are: " +
716
739
strings .Join (maps .Keys (scriptKeyTypeMap ), ", " ),
740
+ Value : "bip86" ,
741
+ },
742
+ cli.BoolFlag {
743
+ Name : scriptKeyTypeAll ,
744
+ Usage : "show all assets, regardless of the script " +
745
+ "key type; cannot be used at the same time " +
746
+ "as --" + scriptKeyTypeName ,
717
747
},
718
748
},
719
749
Action : listAssets ,
@@ -761,6 +791,13 @@ var listUtxosCommand = cli.Command{
761
791
Usage : "filter assets by the type of script key they " +
762
792
"use; possible values are: " +
763
793
strings .Join (maps .Keys (scriptKeyTypeMap ), ", " ),
794
+ Value : "bip86" ,
795
+ },
796
+ cli.BoolFlag {
797
+ Name : scriptKeyTypeAll ,
798
+ Usage : "show all assets, regardless of the script " +
799
+ "key type; cannot be used at the same time " +
800
+ "as --" + scriptKeyTypeName ,
764
801
},
765
802
},
766
803
Action : listUtxos ,
@@ -840,6 +877,13 @@ var listAssetBalancesCommand = cli.Command{
840
877
Usage : "filter assets by the type of script key they " +
841
878
"use; possible values are: " +
842
879
strings .Join (maps .Keys (scriptKeyTypeMap ), ", " ),
880
+ Value : "bip86" ,
881
+ },
882
+ cli.BoolFlag {
883
+ Name : scriptKeyTypeAll ,
884
+ Usage : "show all assets, regardless of the script " +
885
+ "key type; cannot be used at the same time " +
886
+ "as --" + scriptKeyTypeName ,
843
887
},
844
888
},
845
889
}
@@ -1212,3 +1256,53 @@ func fetchMeta(ctx *cli.Context) error {
1212
1256
printRespJSON (resp )
1213
1257
return nil
1214
1258
}
1259
+
1260
+ var removeUtxoLeaseCommand = cli.Command {
1261
+ Name : "removelease" ,
1262
+ ShortName : "rl" ,
1263
+ Usage : "release the lease/lock/reservation on an asset UTXO" ,
1264
+ Description : `
1265
+ Allows the caller to release the lease/lock/reservation that is put on
1266
+ an asset UTXO when it is used in a transaction. The lease is to prevent
1267
+ the asset UTXO from being used in another transaction while the current
1268
+ transaction is being signed and broadcast. If the transaction fails to
1269
+ broadcast, the lease will remain in place for up to 10 minutes. With
1270
+ this command, the caller can release the lease early, allowing the
1271
+ UTXO to be used in another transaction immediately.
1272
+
1273
+ This command either returns an empty response ({}), or an error if the
1274
+ lease could not be released.
1275
+ ` ,
1276
+ Flags : []cli.Flag {
1277
+ cli.StringFlag {
1278
+ Name : outpointName ,
1279
+ Usage : "the outpoint (<txid>:<vout>) of the UTXO to " +
1280
+ "release the lease for" ,
1281
+ },
1282
+ },
1283
+ Action : removeUtxoLease ,
1284
+ }
1285
+
1286
+ func removeUtxoLease (ctx * cli.Context ) error {
1287
+ ctxc := getContext ()
1288
+ client , cleanUp := getWalletClient (ctx )
1289
+ defer cleanUp ()
1290
+
1291
+ outpoint , err := wire .NewOutPointFromString (ctx .String (outpointName ))
1292
+ if err != nil {
1293
+ return fmt .Errorf ("error parsing outpoint: %w" , err )
1294
+ }
1295
+
1296
+ resp , err := client .RemoveUTXOLease (ctxc , & wrpc.RemoveUTXOLeaseRequest {
1297
+ Outpoint : & taprpc.OutPoint {
1298
+ Txid : outpoint .Hash [:],
1299
+ OutputIndex : outpoint .Index ,
1300
+ },
1301
+ })
1302
+ if err != nil {
1303
+ return fmt .Errorf ("unable to remove utxo lease: %w" , err )
1304
+ }
1305
+
1306
+ printRespJSON (resp )
1307
+ return nil
1308
+ }
0 commit comments