multi: add label to WalletController SendOutputs and dependent rpcs

Add a label parameter to the WalletController SendOutputs endpoint and
update rpcs that use it to allow optional provision of labels.
This commit is contained in:
carla committed 2020-05-19 13:31:51 +02:00
1 parent 75370ce6b4
commit 099161ed0b
10 files changed
+773 -692

No files matched your search

+25
View File
@@ -3,6 +3,31 @@
// package to avoid dependency issues.
package labels
import (
"fmt"
"github.com/btcsuite/btcwallet/wtxmgr"
)
// External labels a transaction as user initiated via the api. This
// label is only used when a custom user provided label is not given.
const External = "external"
// ValidateAPI returns the generic api label if the label provided is empty.
// This allows us to label all transactions published by the api, even if
// no label is provided. If a label is provided, it is validated against
// the known restrictions.
func ValidateAPI(label string) (string, error) {
if len(label) > wtxmgr.TxLabelLimit {
return "", fmt.Errorf("label length: %v exceeds "+
"limit of %v", len(label), wtxmgr.TxLabelLimit)
}
// If no label was provided by the user, add the generic user
// send label.
if len(label) == 0 {
return External, nil
}
return label, nil
}