mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-19 20:15:18 +02:00
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:
@@ -79,7 +79,7 @@ type ChainArbitratorConfig struct {
|
||||
// PublishTx reliably broadcasts a transaction to the network. Once
|
||||
// this function exits without an error, then they transaction MUST
|
||||
// continually be rebroadcast if needed.
|
||||
PublishTx func(*wire.MsgTx) error
|
||||
PublishTx func(*wire.MsgTx, string) error
|
||||
|
||||
// DeliverResolutionMsg is a function that will append an outgoing
|
||||
// message to the "out box" for a ChannelLink. This is used to cancel
|
||||
@@ -699,7 +699,7 @@ func (c *ChainArbitrator) rebroadcast(channel *channeldb.OpenChannel,
|
||||
log.Infof("Re-publishing %s close tx(%v) for channel %v",
|
||||
kind, closeTx.TxHash(), chanPoint)
|
||||
|
||||
err = c.cfg.PublishTx(closeTx)
|
||||
err = c.cfg.PublishTx(closeTx, "")
|
||||
if err != nil && err != lnwallet.ErrDoubleSpend {
|
||||
log.Warnf("Unable to broadcast %s close tx(%v): %v",
|
||||
kind, closeTx.TxHash(), err)
|
||||
|
@@ -82,7 +82,7 @@ func TestChainArbitratorRepublishCloses(t *testing.T) {
|
||||
chainArbCfg := ChainArbitratorConfig{
|
||||
ChainIO: &mockChainIO{},
|
||||
Notifier: &mockNotifier{},
|
||||
PublishTx: func(tx *wire.MsgTx) error {
|
||||
PublishTx: func(tx *wire.MsgTx, _ string) error {
|
||||
published[tx.TxHash()]++
|
||||
return nil
|
||||
},
|
||||
@@ -174,7 +174,7 @@ func TestResolveContract(t *testing.T) {
|
||||
chainArbCfg := ChainArbitratorConfig{
|
||||
ChainIO: &mockChainIO{},
|
||||
Notifier: &mockNotifier{},
|
||||
PublishTx: func(tx *wire.MsgTx) error {
|
||||
PublishTx: func(tx *wire.MsgTx, _ string) error {
|
||||
return nil
|
||||
},
|
||||
Clock: clock.NewDefaultClock(),
|
||||
|
@@ -851,7 +851,7 @@ func (c *ChannelArbitrator) stateStep(
|
||||
|
||||
// At this point, we'll now broadcast the commitment
|
||||
// transaction itself.
|
||||
if err := c.cfg.PublishTx(closeTx); err != nil {
|
||||
if err := c.cfg.PublishTx(closeTx, ""); err != nil {
|
||||
log.Errorf("ChannelArbitrator(%v): unable to broadcast "+
|
||||
"close tx: %v", c.cfg.ChanPoint, err)
|
||||
if err != lnwallet.ErrDoubleSpend {
|
||||
|
@@ -324,7 +324,7 @@ func createTestChannelArbitrator(t *testing.T, log ArbitratorLog,
|
||||
mockSweeper := newMockSweeper()
|
||||
chainArbCfg := ChainArbitratorConfig{
|
||||
ChainIO: chainIO,
|
||||
PublishTx: func(*wire.MsgTx) error {
|
||||
PublishTx: func(*wire.MsgTx, string) error {
|
||||
return nil
|
||||
},
|
||||
DeliverResolutionMsg: func(msgs ...ResolutionMsg) error {
|
||||
@@ -575,7 +575,7 @@ func TestChannelArbitratorLocalForceClose(t *testing.T) {
|
||||
// We create a channel we can use to pause the ChannelArbitrator at the
|
||||
// point where it broadcasts the close tx, and check its state.
|
||||
stateChan := make(chan ArbitratorState)
|
||||
chanArb.cfg.PublishTx = func(*wire.MsgTx) error {
|
||||
chanArb.cfg.PublishTx = func(*wire.MsgTx, string) error {
|
||||
// When the force close tx is being broadcasted, check that the
|
||||
// state is correct at that point.
|
||||
select {
|
||||
@@ -998,7 +998,7 @@ func TestChannelArbitratorLocalForceCloseRemoteConfirmed(t *testing.T) {
|
||||
// Create a channel we can use to assert the state when it publishes
|
||||
// the close tx.
|
||||
stateChan := make(chan ArbitratorState)
|
||||
chanArb.cfg.PublishTx = func(*wire.MsgTx) error {
|
||||
chanArb.cfg.PublishTx = func(*wire.MsgTx, string) error {
|
||||
// When the force close tx is being broadcasted, check that the
|
||||
// state is correct at that point.
|
||||
select {
|
||||
@@ -1106,7 +1106,7 @@ func TestChannelArbitratorLocalForceDoubleSpend(t *testing.T) {
|
||||
|
||||
// Return ErrDoubleSpend when attempting to publish the tx.
|
||||
stateChan := make(chan ArbitratorState)
|
||||
chanArb.cfg.PublishTx = func(*wire.MsgTx) error {
|
||||
chanArb.cfg.PublishTx = func(*wire.MsgTx, string) error {
|
||||
// When the force close tx is being broadcasted, check that the
|
||||
// state is correct at that point.
|
||||
select {
|
||||
@@ -1339,7 +1339,7 @@ func TestChannelArbitratorForceCloseBreachedChannel(t *testing.T) {
|
||||
// unexpected publication error, causing the state machine to halt.
|
||||
expErr := errors.New("intentional publication error")
|
||||
stateChan := make(chan ArbitratorState)
|
||||
chanArb.cfg.PublishTx = func(*wire.MsgTx) error {
|
||||
chanArb.cfg.PublishTx = func(*wire.MsgTx, string) error {
|
||||
// When the force close tx is being broadcasted, check that the
|
||||
// state is correct at that point.
|
||||
select {
|
||||
|
@@ -155,7 +155,7 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
||||
// Regardless of whether an existing transaction was found or newly
|
||||
// constructed, we'll broadcast the sweep transaction to the
|
||||
// network.
|
||||
err := h.PublishTx(h.sweepTx)
|
||||
err := h.PublishTx(h.sweepTx, "")
|
||||
if err != nil {
|
||||
log.Infof("%T(%x): unable to publish tx: %v",
|
||||
h, h.htlc.RHash[:], err)
|
||||
@@ -199,7 +199,7 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
||||
// the claiming process.
|
||||
//
|
||||
// TODO(roasbeef): after changing sighashes send to tx bundler
|
||||
err := h.PublishTx(h.htlcResolution.SignedSuccessTx)
|
||||
err := h.PublishTx(h.htlcResolution.SignedSuccessTx, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user