PendingSweeps
PendingSweeps returns lists of on-chain outputs that lnd is currently attempting to sweep within its central batching engine. Outputs with similar fee rates are batched together in order to sweep them within a single transaction.
NOTE: Some of the fields within PendingSweepsRequest are not guaranteed to remain supported. This is an advanced API that depends on the internals of the UtxoSweeper, so things may change.
Source: walletrpc/walletkit.proto
gRPC
rpc PendingSweeps (PendingSweepsRequest) returns (PendingSweepsResponse);
REST
HTTP Method | Path |
---|---|
GET | /v2/wallet/sweeps/pending |
Code Samples
- gRPC
- REST
- Shell
- Javascript
- Python
const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const GRPC_HOST = 'localhost:10009'
const MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
const TLS_PATH = 'LND_DIR/tls.cert'
const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync(['lightning.proto', 'walletrpc/walletkit.proto'], loaderOptions);
const walletrpc = grpc.loadPackageDefinition(packageDefinition).walletrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new walletrpc.WalletKit(GRPC_HOST, creds);
let request = {};
client.pendingSweeps(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "pending_sweeps": <PendingSweep>,
// }
import codecs, grpc, os
# Generate the following 2 modules by compiling the walletrpc/walletkit.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import walletkit_pb2 as walletrpc, walletkit_pb2_grpc as walletkitstub
GRPC_HOST = 'localhost:10009'
MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
TLS_PATH = 'LND_DIR/tls.cert'
# create macaroon credentials
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
def metadata_callback(context, callback):
callback([('macaroon', macaroon)], None)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
# create SSL credentials
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
cert = open(TLS_PATH, 'rb').read()
ssl_creds = grpc.ssl_channel_credentials(cert)
# combine macaroon and SSL credentials
combined_creds = grpc.composite_channel_credentials(ssl_creds, auth_creds)
# make the request
channel = grpc.secure_channel(GRPC_HOST, combined_creds)
stub = walletkitstub.WalletKitStub(channel)
request = walletrpc.PendingSweepsRequest()
response = stub.PendingSweeps(request)
print(response)
# {
# "pending_sweeps": <PendingSweep>,
# }
- Javascript
- Python
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8080'
const MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
let options = {
url: `https://${REST_HOST}/v2/wallet/sweeps/pending`,
// Work-around for self-signed certificates.
rejectUnauthorized: false,
json: true,
headers: {
'Grpc-Metadata-macaroon': fs.readFileSync(MACAROON_PATH).toString('hex'),
},
}
request.get(options, function(error, response, body) {
console.log(body);
});
// Console output:
// {
// "pending_sweeps": <array>, // <PendingSweep>
// }
import base64, codecs, json, requests
REST_HOST = 'localhost:8080'
MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
TLS_PATH = 'LND_DIR/tls.cert'
url = f'https://{REST_HOST}/v2/wallet/sweeps/pending'
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
headers = {'Grpc-Metadata-macaroon': macaroon}
r = requests.get(url, headers=headers, verify=TLS_PATH)
print(r.json())
# {
# "pending_sweeps": <PendingSweep>,
# }
$ lncli wallet pendingsweeps --help
NAME:
lncli wallet pendingsweeps - List all outputs that are pending to be swept within lnd.
USAGE:
lncli wallet pendingsweeps [arguments...]
DESCRIPTION:
List all on-chain outputs that lnd is currently attempting to sweep
within its central batching engine. Outputs with similar fee rates are
batched together in order to sweep them within a single transaction.
Messages
walletrpc.PendingSweepsRequest
Source: walletrpc/walletkit.proto
note
This request has no parameters.
walletrpc.PendingSweepsResponse
Source: walletrpc/walletkit.proto
Field | gRPC Type | REST Type |
---|---|---|
pending_sweeps | PendingSweep[] | array |
Nested Messages
lnrpc.OutPoint
Field | gRPC Type | REST Type |
---|---|---|
txid_bytes | bytes | string |
txid_str | string | string |
output_index | uint32 | integer |
walletrpc.PendingSweep
Field | gRPC Type | REST Type |
---|---|---|
outpoint | OutPoint | object |
witness_type | WitnessType | string |
amount_sat | uint32 | integer |
sat_per_byte deprecated | uint32 | integer |
broadcast_attempts | uint32 | integer |
next_broadcast_height deprecated | uint32 | integer |
force deprecated | bool | boolean |
requested_conf_target deprecated | uint32 | integer |
requested_sat_per_byte deprecated | uint32 | integer |
sat_per_vbyte | uint64 | string |
requested_sat_per_vbyte | uint64 | string |
immediate | bool | boolean |
budget | uint64 | string |
deadline_height | uint32 | integer |
Enums
walletrpc.WitnessType
Name | Number |
---|---|
UNKNOWN_WITNESS | 0 |
COMMITMENT_TIME_LOCK | 1 |
COMMITMENT_NO_DELAY | 2 |
COMMITMENT_REVOKE | 3 |
HTLC_OFFERED_REVOKE | 4 |
HTLC_ACCEPTED_REVOKE | 5 |
HTLC_OFFERED_TIMEOUT_SECOND_LEVEL | 6 |
HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL | 7 |
HTLC_OFFERED_REMOTE_TIMEOUT | 8 |
HTLC_ACCEPTED_REMOTE_SUCCESS | 9 |
HTLC_SECOND_LEVEL_REVOKE | 10 |
WITNESS_KEY_HASH | 11 |
NESTED_WITNESS_KEY_HASH | 12 |
COMMITMENT_ANCHOR | 13 |
COMMITMENT_NO_DELAY_TWEAKLESS | 14 |
COMMITMENT_TO_REMOTE_CONFIRMED | 15 |
HTLC_OFFERED_TIMEOUT_SECOND_LEVEL_INPUT_CONFIRMED | 16 |
HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL_INPUT_CONFIRMED | 17 |
LEASE_COMMITMENT_TIME_LOCK | 18 |
LEASE_COMMITMENT_TO_REMOTE_CONFIRMED | 19 |
LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL | 20 |
LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL | 21 |
TAPROOT_PUB_KEY_SPEND | 22 |
TAPROOT_LOCAL_COMMIT_SPEND | 23 |
TAPROOT_REMOTE_COMMIT_SPEND | 24 |
TAPROOT_ANCHOR_SWEEP_SPEND | 25 |
TAPROOT_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL | 26 |
TAPROOT_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL | 27 |
TAPROOT_HTLC_SECOND_LEVEL_REVOKE | 28 |
TAPROOT_HTLC_ACCEPTED_REVOKE | 29 |
TAPROOT_HTLC_OFFERED_REVOKE | 30 |
TAPROOT_HTLC_OFFERED_REMOTE_TIMEOUT | 31 |
TAPROOT_HTLC_LOCAL_OFFERED_TIMEOUT | 32 |
TAPROOT_HTLC_ACCEPTED_REMOTE_SUCCESS | 33 |
TAPROOT_HTLC_ACCEPTED_LOCAL_SUCCESS | 34 |
TAPROOT_COMMITMENT_REVOKE | 35 |