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

+5 -2
View File
@@ -294,7 +294,7 @@ func (b *BtcWallet) IsOurAddress(a btcutil.Address) bool {
//
// This is a part of the WalletController interface.
func (b *BtcWallet) SendOutputs(outputs []*wire.TxOut,
feeRate chainfee.SatPerKWeight) (*wire.MsgTx, error) {
feeRate chainfee.SatPerKWeight, label string) (*wire.MsgTx, error) {
// Convert our fee rate from sat/kw to sat/kb since it's required by
// SendOutputs.
@@ -304,7 +304,10 @@ func (b *BtcWallet) SendOutputs(outputs []*wire.TxOut,
if len(outputs) < 1 {
return nil, lnwallet.ErrNoOutputs
}
return b.wallet.SendOutputs(outputs, defaultAccount, 1, feeSatPerKB, "")
return b.wallet.SendOutputs(
outputs, defaultAccount, 1, feeSatPerKB, label,
)
}
// CreateSimpleTx creates a Bitcoin transaction paying to the specified
+1 -1
View File
@@ -174,7 +174,7 @@ type WalletController interface {
// This method also takes the target fee expressed in sat/kw that should
// be used when crafting the transaction.
SendOutputs(outputs []*wire.TxOut,
feeRate chainfee.SatPerKWeight) (*wire.MsgTx, error)
feeRate chainfee.SatPerKWeight, label string) (*wire.MsgTx, error)
// CreateSimpleTx creates a Bitcoin transaction paying to the specified
// outputs. The transaction is not broadcasted to the network. In the
+19 -7
View File
@@ -174,7 +174,9 @@ func sendCoins(t *testing.T, miner *rpctest.Harness,
t.Helper()
tx, err := sender.SendOutputs([]*wire.TxOut{output}, 2500)
tx, err := sender.SendOutputs(
[]*wire.TxOut{output}, 2500, labels.External,
)
if err != nil {
t.Fatalf("unable to send transaction: %v", err)
}
@@ -1220,7 +1222,9 @@ func testListTransactionDetails(miner *rpctest.Harness,
t.Fatalf("unable to make output script: %v", err)
}
burnOutput := wire.NewTxOut(outputAmt, outputScript)
burnTX, err := alice.SendOutputs([]*wire.TxOut{burnOutput}, 2500)
burnTX, err := alice.SendOutputs(
[]*wire.TxOut{burnOutput}, 2500, labels.External,
)
if err != nil {
t.Fatalf("unable to create burn tx: %v", err)
}
@@ -1493,7 +1497,9 @@ func testTransactionSubscriptions(miner *rpctest.Harness,
t.Fatalf("unable to make output script: %v", err)
}
burnOutput := wire.NewTxOut(outputAmt, outputScript)
tx, err := alice.SendOutputs([]*wire.TxOut{burnOutput}, 2500)
tx, err := alice.SendOutputs(
[]*wire.TxOut{burnOutput}, 2500, labels.External,
)
if err != nil {
t.Fatalf("unable to create burn tx: %v", err)
}
@@ -1684,7 +1690,9 @@ func newTx(t *testing.T, r *rpctest.Harness, pubKey *btcec.PublicKey,
Value: btcutil.SatoshiPerBitcoin,
PkScript: keyScript,
}
tx, err := alice.SendOutputs([]*wire.TxOut{newOutput}, 2500)
tx, err := alice.SendOutputs(
[]*wire.TxOut{newOutput}, 2500, labels.External,
)
if err != nil {
t.Fatalf("unable to create output: %v", err)
}
@@ -1973,7 +1981,9 @@ func testSignOutputUsingTweaks(r *rpctest.Harness,
Value: btcutil.SatoshiPerBitcoin,
PkScript: keyScript,
}
tx, err := alice.SendOutputs([]*wire.TxOut{newOutput}, 2500)
tx, err := alice.SendOutputs(
[]*wire.TxOut{newOutput}, 2500, labels.External,
)
if err != nil {
t.Fatalf("unable to create output: %v", err)
}
@@ -2095,7 +2105,9 @@ func testReorgWalletBalance(r *rpctest.Harness, w *lnwallet.LightningWallet,
Value: 1e8,
PkScript: script,
}
tx, err := w.SendOutputs([]*wire.TxOut{output}, 2500)
tx, err := w.SendOutputs(
[]*wire.TxOut{output}, 2500, labels.External,
)
if err != nil {
t.Fatalf("unable to send outputs: %v", err)
}
@@ -2476,7 +2488,7 @@ func testCreateSimpleTx(r *rpctest.Harness, w *lnwallet.LightningWallet,
// _very_ similar to the one we just created being sent. The
// only difference is that the dry run tx is not signed, and
// that the change output position might be different.
tx, sendErr := w.SendOutputs(outputs, feeRate)
tx, sendErr := w.SendOutputs(outputs, feeRate, labels.External)
switch {
case test.valid && sendErr != nil:
t.Fatalf("got unexpected error when sending tx: %v",