wavecli wallet-sweepSweepWallet
SweepWallet previews or broadcasts a normal backing-wallet sweep to a caller-supplied Bitcoin address. This sweeps wallet-managed funds left after CPFP/change/unroll proceeds and does not sweep boarding outputs.
Endpoints
rpc SweepWallet(SweepWalletRequest) returns (SweepWalletResponse)POST/v1/wallet/sweep-walletExamples
wavecli wallet-sweep --destination bcrt1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlhwavecli wallet-sweep --destination bcrt1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlhconn, err := grpc.NewClient("localhost:10029",
grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatal(err)
}
defer conn.Close()
client := wavewalletrpc.NewWalletServiceClient(conn)
ctx := context.Background()
req := &wavewalletrpc.SweepWalletRequest{
DestinationAddress: "bcrt1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
Broadcast: false,
}
resp, err := client.SweepWallet(ctx, req)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp)import grpc
import wallet_pb2
import wallet_pb2_grpc
channel = grpc.insecure_channel('localhost:10029')
stub = wallet_pb2_grpc.WalletServiceStub(channel)
request = wallet_pb2.SweepWalletRequest(
destination_address="bcrt1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
broadcast=False,
)
response = stub.SweepWallet(request)
print(response)const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const packageDefinition = protoLoader.loadSync('wallet.proto');
const { wavewalletrpc } = grpc.loadPackageDefinition(packageDefinition);
const client = new wavewalletrpc.WalletService(
'localhost:10029',
grpc.credentials.createInsecure(),
);
const request = {
"destination_address": "bcrt1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
"broadcast": false
};
// Calls wavewalletrpc.WalletService.SweepWallet.
client.sweepWallet(request, (err, response) => {
if (err) throw err;
console.log(response);
});curl -X POST http://localhost:10031/v1/wallet/sweep-wallet \
-H 'Content-Type: application/json' \
-d '{"destination_address":"bcrt1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh","broadcast":false}'const res = await fetch('http://localhost:10031/v1/wallet/sweep-wallet', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"destination_address": "bcrt1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
"broadcast": false
}),
});
const sweepWalletResponse = await res.json();RequestSweepWalletRequest
SweepWalletRequest describes a backing-wallet sweep to preview or broadcast via WalletService.SweepWallet.
| Field | Type | Description |
|---|---|---|
destination_address | string | destination_address is the Bitcoin address that receives the backing wallet funds after fees. |
broadcast | bool | broadcast controls whether the sweep is only previewed or also signed and published. |
fee_rate_sat_per_vbyte | int64 | fee_rate_sat_per_vbyte overrides chain fee estimation when positive. |
conf_target | uint32 | conf_target selects the fee-estimation target in blocks when fee_rate_sat_per_vbyte is unset. Zero uses the daemon's default unroll confirmation target. |
ResponseSweepWalletResponse
SweepWalletResponse is the preview or broadcast result of WalletService.SweepWallet.
| Field | Type | Description |
|---|---|---|
inputs | repeated WalletSweepInput | inputs are the confirmed backing-wallet UTXOs selected for the sweep. |
total_input_sat | int64 | total_input_sat is the gross value in satoshis of every selected input. |
estimated_fee_sat | int64 | estimated_fee_sat is the absolute miner fee in satoshis for the aggregate sweep transaction at the resolved fee rate. |
net_amount_sat | int64 | net_amount_sat is total_input_sat minus estimated_fee_sat: the amount in satoshis paid to the destination address. |
fee_rate_sat_per_vbyte | int64 | fee_rate_sat_per_vbyte is the (capped) fee rate used to build the sweep transaction. |
can_broadcast | bool | can_broadcast is true when the preview cleared the dust floor and the sweep can be published. |
txid | string | txid is the hex-encoded sweep transaction id, set only when the sweep was broadcast. |
failure_reason | string | failure_reason is populated when the sweep cannot broadcast (no confirmed inputs, dust after fees) or the broadcast failed after preview. |
WalletSweepInputmessage
WalletSweepInput is one backing-wallet UTXO selected for a sweep.
| Field | Type | Description |
|---|---|---|
outpoint | string | outpoint is the selected backing-wallet UTXO, formatted as "txid:index". |
amount_sat | int64 | amount_sat is the value of the selected UTXO in satoshis. |