multi: update WalletController PublishTransaction to include label

Add label parameter to PublishTransaction in WalletController
interface. A labels package is added to store generic labels that are
used for the different types of transactions that are published by lnd.

To keep commit size down, the two endpoints that require a label
parameter be passed down have a todo added, which will be removed in
subsequent commits.
This commit is contained in:
carla committed 2020-05-19 13:30:00 +02:00
1 parent c2516d9352
commit 75370ce6b4
25 files changed
+74 -52

No files matched your search

+20 -11
View File
@@ -38,6 +38,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb/kvdb"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/labels"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
@@ -529,7 +530,8 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
}
// Let Alice publish the funding transaction.
if err := alice.PublishTransaction(fundingTx); err != nil {
err = alice.PublishTransaction(fundingTx, "")
if err != nil {
t.Fatalf("unable to publish funding tx: %v", err)
}
@@ -1024,7 +1026,8 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
}
// Let Alice publish the funding transaction.
if err := alice.PublishTransaction(fundingTx); err != nil {
err = alice.PublishTransaction(fundingTx, "")
if err != nil {
t.Fatalf("unable to publish funding tx: %v", err)
}
@@ -1721,7 +1724,8 @@ func testPublishTransaction(r *rpctest.Harness,
tx1 := newTx(t, r, keyDesc.PubKey, alice, false)
// Publish the transaction.
if err := alice.PublishTransaction(tx1); err != nil {
err = alice.PublishTransaction(tx1, labels.External)
if err != nil {
t.Fatalf("unable to publish: %v", err)
}
@@ -1733,7 +1737,8 @@ func testPublishTransaction(r *rpctest.Harness,
// Publish the exact same transaction again. This should not return an
// error, even though the transaction is already in the mempool.
if err := alice.PublishTransaction(tx1); err != nil {
err = alice.PublishTransaction(tx1, labels.External)
if err != nil {
t.Fatalf("unable to publish: %v", err)
}
@@ -1752,7 +1757,8 @@ func testPublishTransaction(r *rpctest.Harness,
tx2 := newTx(t, r, keyDesc.PubKey, alice, false)
// Publish this tx.
if err := alice.PublishTransaction(tx2); err != nil {
err = alice.PublishTransaction(tx2, labels.External)
if err != nil {
t.Fatalf("unable to publish: %v", err)
}
@@ -1763,7 +1769,8 @@ func testPublishTransaction(r *rpctest.Harness,
// Publish the transaction again. It is already mined, and we don't
// expect this to return an error.
if err := alice.PublishTransaction(tx2); err != nil {
err = alice.PublishTransaction(tx2, labels.External)
if err != nil {
t.Fatalf("unable to publish: %v", err)
}
@@ -1779,7 +1786,8 @@ func testPublishTransaction(r *rpctest.Harness,
// transaction. Create a new tx and publish it. This is the
// output we'll try to double spend.
tx3 = newTx(t, r, keyDesc.PubKey, alice, false)
if err := alice.PublishTransaction(tx3); err != nil {
err := alice.PublishTransaction(tx3, labels.External)
if err != nil {
t.Fatalf("unable to publish: %v", err)
}
@@ -1799,7 +1807,8 @@ func testPublishTransaction(r *rpctest.Harness,
}
// This should be accepted into the mempool.
if err := alice.PublishTransaction(tx4); err != nil {
err = alice.PublishTransaction(tx4, labels.External)
if err != nil {
t.Fatalf("unable to publish: %v", err)
}
@@ -1833,7 +1842,7 @@ func testPublishTransaction(r *rpctest.Harness,
t.Fatal(err)
}
err = alice.PublishTransaction(tx5)
err = alice.PublishTransaction(tx5, labels.External)
if err != lnwallet.ErrDoubleSpend {
t.Fatalf("expected ErrDoubleSpend, got: %v", err)
}
@@ -1861,7 +1870,7 @@ func testPublishTransaction(r *rpctest.Harness,
expErr = nil
tx3Spend = tx6
}
err = alice.PublishTransaction(tx6)
err = alice.PublishTransaction(tx6, labels.External)
if err != expErr {
t.Fatalf("expected ErrDoubleSpend, got: %v", err)
}
@@ -1896,7 +1905,7 @@ func testPublishTransaction(r *rpctest.Harness,
}
// Expect rejection.
err = alice.PublishTransaction(tx7)
err = alice.PublishTransaction(tx7, labels.External)
if err != lnwallet.ErrDoubleSpend {
t.Fatalf("expected ErrDoubleSpend, got: %v", err)
}