walletrpc: add default values to listunspent
This commit is contained in:
1 parent
9a50cc95b7
commit
74db83bbfb
7 files changed
+485
-436
No files matched your search
@@ -10,6 +10,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
@@ -322,16 +323,29 @@ func (w *WalletKit) internalScope() waddrmgr.KeyScope {
|
||||
}
|
||||
}
|
||||
|
||||
// ListUnspent returns useful information about each unspent output owned by the
|
||||
// wallet, as reported by the underlying `ListUnspentWitness`; the information
|
||||
// returned is: outpoint, amount in satoshis, address, address type,
|
||||
// scriptPubKey in hex and number of confirmations. The result is filtered to
|
||||
// contain outputs whose number of confirmations is between a
|
||||
// minimum and maximum number of confirmations specified by the user, with 0
|
||||
// meaning unconfirmed.
|
||||
// ListUnspent returns useful information about each unspent output owned by
|
||||
// the wallet, as reported by the underlying `ListUnspentWitness`; the
|
||||
// information returned is: outpoint, amount in satoshis, address, address
|
||||
// type, scriptPubKey in hex and number of confirmations. The result is
|
||||
// filtered to contain outputs whose number of confirmations is between a
|
||||
// minimum and maximum number of confirmations specified by the user.
|
||||
func (w *WalletKit) ListUnspent(ctx context.Context,
|
||||
req *ListUnspentRequest) (*ListUnspentResponse, error) {
|
||||
|
||||
// Force min_confs and max_confs to be zero if unconfirmed_only is
|
||||
// true.
|
||||
if req.UnconfirmedOnly && (req.MinConfs != 0 || req.MaxConfs != 0) {
|
||||
return nil, fmt.Errorf("min_confs and max_confs must be zero if " +
|
||||
"unconfirmed_only is true")
|
||||
}
|
||||
|
||||
// When unconfirmed_only is inactive and max_confs is zero (default
|
||||
// values), we will override max_confs to be a MaxInt32, in order
|
||||
// to return all confirmed and unconfirmed utxos as a default response.
|
||||
if req.MaxConfs == 0 && !req.UnconfirmedOnly {
|
||||
req.MaxConfs = math.MaxInt32
|
||||
}
|
||||
|
||||
// Validate the confirmation arguments.
|
||||
minConfs, maxConfs, err := lnrpc.ParseConfs(req.MinConfs, req.MaxConfs)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user