From 0cfe15c0c74930f85c95f7329c973c1d5a61813f Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 12 Sep 2018 18:30:01 -0700 Subject: [PATCH] wallet: allow SendOutputs to notify new outgoing transactions for neutrino In this commit, we modify the SendOutputs method to also notify new outgoing transctions for neutriino. For the full node backends, they'll get this notification when the transactino hits the mempool. However, for neutrino it will only be notified once the transaction has been confirmed. This commit ensures that we'll notify on send as well. --- wallet/wallet.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/wallet/wallet.go b/wallet/wallet.go index 0a89ef4..a9ae3ca 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -3132,7 +3132,26 @@ func (w *Wallet) SendOutputs(outputs []*wire.TxOut, account uint32, // TODO: The record already has the serialized tx, so no need to // serialize it again. - return chainClient.SendRawTransaction(&rec.MsgTx, false) + txid, err := chainClient.SendRawTransaction(&rec.MsgTx, false) + switch { + case err == nil: + switch w.chainClient.(type) { + // For neutrino we need to trigger adding relevant tx manually + // because for spv client - tx data isn't received from sync peer. + case *chain.NeutrinoClient: + err := walletdb.Update(w.db, func(tx walletdb.ReadWriteTx) error { + return w.addRelevantTx(tx, rec, nil) + }) + if err != nil { + return nil, err + } + } + + // TODO(roasbeef): properly act on rest of mapped errors + return txid, nil + default: + return nil, err + } } // SignatureError records the underlying error when validating a transaction