From ee841b07cfcc77a1b377dd1aff7ace843293177b Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 1 Oct 2017 14:36:19 -0700 Subject: [PATCH] wallet: for ineutrino back-end insert all broadcast transactions into txstore --- wallet/wallet.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/wallet/wallet.go b/wallet/wallet.go index 6388008..9e156f9 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -2510,7 +2510,7 @@ func (w *Wallet) SignTransaction(tx *wire.MsgTx, hashType txscript.SigHashType, } // PublishTransaction sends the transaction to the consensus RPC server so it -// can be propigated to other nodes and eventually mined. +// can be propagated to other nodes and eventually mined. // // This function is unstable and will be removed once syncing code is moved out // of the wallet. @@ -2520,6 +2520,28 @@ func (w *Wallet) PublishTransaction(tx *wire.MsgTx) error { return err } + switch server.(type) { + // If our chain backend is neutrino, then we'll add this as an + // unconfirmed transaction into the transaction store. Otherwise, we + // won't eve be notified of it's acceptance, meaning we won't attempt + // to re-broadcast. + case *chain.NeutrinoClient: + rec, err := wtxmgr.NewTxRecordFromMsgTx( + tx, time.Now(), + ) + if err != nil { + return err + } + err = walletdb.Update(w.db, func(tx walletdb.ReadWriteTx) error { + txmgrNs := tx.ReadWriteBucket(wtxmgrNamespaceKey) + + return w.TxStore.InsertTx(txmgrNs, rec, nil) + }) + if err != nil { + return err + } + } + _, err = server.SendRawTransaction(tx, false) return err }