diff --git a/chain/sync.go b/chain/sync.go index ae0228d8f..1a8d3a9ff 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -410,7 +410,7 @@ func (s *Syncer) Run(ctx context.Context) (err error) { } s.sidechainsMu.Lock() - prevChain, err := s.wallet.ChainSwitch(&s.sidechains, bestChain, nil) + prevChain, err := s.wallet.ChainSwitch(ctx, &s.sidechains, bestChain, nil) s.sidechainsMu.Unlock() if err != nil { return err @@ -575,7 +575,7 @@ func (s *Syncer) winningTickets(ctx context.Context, params json.RawMessage) err if err != nil { return err } - return s.wallet.VoteOnOwnedTickets(winners, block, height) + return s.wallet.VoteOnOwnedTickets(ctx, winners, block, height) } func (s *Syncer) blockConnected(ctx context.Context, params json.RawMessage) error { @@ -603,7 +603,7 @@ func (s *Syncer) blockConnected(ctx context.Context, params json.RawMessage) err } if len(bestChain) != 0 { var prevChain []*wallet.BlockNode - prevChain, err = s.wallet.ChainSwitch(&s.sidechains, bestChain, s.relevantTxs) + prevChain, err = s.wallet.ChainSwitch(ctx, &s.sidechains, bestChain, s.relevantTxs) if err != nil { return err } @@ -637,7 +637,7 @@ func (s *Syncer) relevantTxAccepted(ctx context.Context, params json.RawMessage) if err != nil { return err } - return s.wallet.AcceptMempoolTx(tx) + return s.wallet.AcceptMempoolTx(ctx, tx) } func (s *Syncer) spentAndMissedTickets(ctx context.Context, params json.RawMessage) error { @@ -645,5 +645,5 @@ func (s *Syncer) spentAndMissedTickets(ctx context.Context, params json.RawMessa if err != nil { return err } - return s.wallet.RevokeOwnedTickets(missed) + return s.wallet.RevokeOwnedTickets(ctx, missed) } diff --git a/rpc/jsonrpc/methods.go b/rpc/jsonrpc/methods.go index 973071e73..35aaee8f7 100644 --- a/rpc/jsonrpc/methods.go +++ b/rpc/jsonrpc/methods.go @@ -342,7 +342,7 @@ func (s *Server) accountSyncAddressIndex(ctx context.Context, icmd interface{}) // Additional addresses need to be watched. Since addresses are derived // based on the last used address, this RPC no longer changes the child // indexes that new addresses are derived from. - return nil, w.ExtendWatchedAddresses(account, branch, index) + return nil, w.ExtendWatchedAddresses(ctx, account, branch, index) } func makeMultiSigScript(w *wallet.Wallet, keys []string, nRequired int) ([]byte, error) { @@ -483,7 +483,7 @@ func (s *Server) consolidate(ctx context.Context, icmd interface{}) (interface{} // TODO In the future this should take the optional account and // only consolidate UTXOs found within that account. - txHash, err := w.Consolidate(cmd.Inputs, account, changeAddr) + txHash, err := w.Consolidate(ctx, cmd.Inputs, account, changeAddr) if err != nil { return nil, err } @@ -1040,7 +1040,7 @@ func (s *Server) importPrivKey(ctx context.Context, icmd interface{}) (interface } // Import the private key, handling any errors. - _, err = w.ImportPrivateKey(wif) + _, err = w.ImportPrivateKey(ctx, wif) if err != nil { switch { case errors.Is(errors.Exist, err): @@ -1091,7 +1091,7 @@ func (s *Server) importScript(ctx context.Context, icmd interface{}) (interface{ return nil, rpcErrorf(dcrjson.ErrRPCInvalidParameter, "empty script") } - err = w.ImportScript(rs) + err = w.ImportScript(ctx, rs) if err != nil { switch { case errors.Is(errors.Exist, err): @@ -1129,7 +1129,7 @@ func (s *Server) createNewAccount(ctx context.Context, icmd interface{}) (interf return nil, errReservedAccountName } - _, err := w.NextAccount(cmd.Account) + _, err := w.NextAccount(ctx, cmd.Account) if err != nil { if errors.Is(errors.Locked, err) { return nil, rpcErrorf(dcrjson.ErrRPCWalletUnlockNeeded, "creating new accounts requires an unlocked wallet") @@ -1262,7 +1262,7 @@ func (s *Server) getNewAddress(ctx context.Context, icmd interface{}) (interface return nil, err } - addr, err := w.NewExternalAddress(account, callOpts...) + addr, err := w.NewExternalAddress(ctx, account, callOpts...) if err != nil { return nil, err } @@ -1293,7 +1293,7 @@ func (s *Server) getRawChangeAddress(ctx context.Context, icmd interface{}) (int return nil, err } - addr, err := w.NewChangeAddress(account) + addr, err := w.NewChangeAddress(ctx, account) if err != nil { return nil, err } @@ -2188,7 +2188,7 @@ func (s *Server) purchaseTicket(ctx context.Context, icmd interface{}) (interfac } } - hashes, err := w.PurchaseTickets(0, spendLimit, minConf, ticketAddr, + hashes, err := w.PurchaseTickets(ctx, 0, spendLimit, minConf, ticketAddr, account, numTickets, poolAddr, poolFee, expiry, w.RelayFee(), ticketFee) if err != nil { @@ -2245,12 +2245,12 @@ func makeOutputs(pairs map[string]dcrutil.Amount, chainParams *chaincfg.Params) // sendPairs creates and sends payment transactions. // It returns the transaction hash in string format upon success // All errors are returned in dcrjson.RPCError format -func sendPairs(w *wallet.Wallet, amounts map[string]dcrutil.Amount, account uint32, minconf int32) (string, error) { +func sendPairs(ctx context.Context, w *wallet.Wallet, amounts map[string]dcrutil.Amount, account uint32, minconf int32) (string, error) { outputs, err := makeOutputs(amounts, w.ChainParams()) if err != nil { return "", err } - txSha, err := w.SendOutputs(outputs, account, minconf) + txSha, err := w.SendOutputs(ctx, outputs, account, minconf) if err != nil { if errors.Is(errors.Locked, err) { return "", errWalletUnlockNeeded @@ -2288,7 +2288,7 @@ func (s *Server) redeemMultiSigOut(ctx context.Context, icmd interface{}) (inter } } else { account := uint32(udb.DefaultAccountNum) - addr, err = w.NewInternalAddress(account, wallet.WithGapPolicyWrap()) + addr, err = w.NewInternalAddress(ctx, account, wallet.WithGapPolicyWrap()) if err != nil { return nil, err } @@ -2602,7 +2602,7 @@ func (s *Server) sendFrom(ctx context.Context, icmd interface{}) (interface{}, e cmd.ToAddress: amt, } - return sendPairs(w, pairs, account, minConf) + return sendPairs(ctx, w, pairs, account, minConf) } // sendMany handles a sendmany RPC request by creating a new transaction @@ -2644,7 +2644,7 @@ func (s *Server) sendMany(ctx context.Context, icmd interface{}) (interface{}, e pairs[k] = amt } - return sendPairs(w, pairs, account, minConf) + return sendPairs(ctx, w, pairs, account, minConf) } // sendToAddress handles a sendtoaddress RPC request by creating a new @@ -2681,7 +2681,7 @@ func (s *Server) sendToAddress(ctx context.Context, icmd interface{}) (interface } // sendtoaddress always spends from the default account, this matches bitcoind - return sendPairs(w, pairs, udb.DefaultAccountNum, 1) + return sendPairs(ctx, w, pairs, udb.DefaultAccountNum, 1) } // sendToMultiSig handles a sendtomultisig RPC request by creating a new @@ -2746,7 +2746,7 @@ func (s *Server) sendToMultiSig(ctx context.Context, icmd interface{}) (interfac } tx, addr, script, err := - w.CreateMultisigTx(account, amount, pubkeys, nrequired, minconf) + w.CreateMultisigTx(ctx, account, amount, pubkeys, nrequired, minconf) if err != nil { return nil, err } diff --git a/rpc/rpcserver/server.go b/rpc/rpcserver/server.go index abb40ae8b..d8638784a 100644 --- a/rpc/rpcserver/server.go +++ b/rpc/rpcserver/server.go @@ -437,7 +437,7 @@ func (s *walletServer) NextAccount(ctx context.Context, req *pb.NextAccountReque return nil, translateError(err) } - account, err := s.wallet.NextAccount(req.AccountName) + account, err := s.wallet.NextAccount(ctx, req.AccountName) if err != nil { return nil, translateError(err) } @@ -467,12 +467,12 @@ func (s *walletServer) NextAddress(ctx context.Context, req *pb.NextAddressReque ) switch req.Kind { case pb.NextAddressRequest_BIP0044_EXTERNAL: - addr, err = s.wallet.NewExternalAddress(req.Account, callOpts...) + addr, err = s.wallet.NewExternalAddress(ctx, req.Account, callOpts...) if err != nil { return nil, translateError(err) } case pb.NextAddressRequest_BIP0044_INTERNAL: - addr, err = s.wallet.NewInternalAddress(req.Account, callOpts...) + addr, err = s.wallet.NewInternalAddress(ctx, req.Account, callOpts...) if err != nil { return nil, translateError(err) } @@ -541,7 +541,7 @@ func (s *walletServer) ImportPrivateKey(ctx context.Context, req *pb.ImportPriva return nil, err } - _, err = s.wallet.ImportPrivateKey(wif) + _, err = s.wallet.ImportPrivateKey(ctx, wif) if err != nil { return nil, translateError(err) } @@ -608,7 +608,7 @@ func (s *walletServer) ImportScript(ctx context.Context, return nil, err } - err = s.wallet.ImportScript(req.Script) + err = s.wallet.ImportScript(ctx, req.Script) if err != nil { return nil, translateError(err) } @@ -915,7 +915,7 @@ func (s *walletServer) FundTransaction(ctx context.Context, req *pb.FundTransact var changeScript []byte if req.IncludeChangeScript && inputDetail.Amount > dcrutil.Amount(req.TargetAmount) { - changeAddr, err := s.wallet.NewChangeAddress(req.Account) + changeAddr, err := s.wallet.NewChangeAddress(ctx, req.Account) if err != nil { return nil, translateError(err) } @@ -1524,7 +1524,7 @@ func (s *walletServer) PublishTransaction(ctx context.Context, req *pb.PublishTr "Bytes do not represent a valid raw transaction: %v", err) } - txHash, err := s.wallet.PublishTransaction(&msgTx, req.SignedTransaction, n) + txHash, err := s.wallet.PublishTransaction(ctx, &msgTx, req.SignedTransaction, n) if err != nil { return nil, translateError(err) } @@ -1608,7 +1608,7 @@ func (s *walletServer) PurchaseTickets(ctx context.Context, return nil, translateError(err) } - resp, err := s.wallet.PurchaseTickets(0, spendLimit, minConf, + resp, err := s.wallet.PurchaseTickets(ctx, 0, spendLimit, minConf, ticketAddr, req.Account, numTickets, poolAddr, req.PoolFees, expiry, txFee, ticketFee) if err != nil { diff --git a/spv/sync.go b/spv/sync.go index 2ea69c29c..b80bb5fce 100644 --- a/spv/sync.go +++ b/spv/sync.go @@ -719,7 +719,7 @@ func (s *Syncer) handleTxInvs(ctx context.Context, rp *p2p.RemotePeer, hashes [] // Save any relevant transaction. relevant := s.filterRelevant(txs) for _, tx := range relevant { - err := s.wallet.AcceptMempoolTx(tx) + err := s.wallet.AcceptMempoolTx(ctx, tx) if err != nil { op := errors.Opf(opf, rp.RemoteAddr()) log.Warn(errors.E(op, err)) @@ -946,7 +946,7 @@ func (s *Syncer) handleBlockAnnouncements(ctx context.Context, rp *p2p.RemotePee } } - prevChain, err := s.wallet.ChainSwitch(&s.sidechains, bestChain, matchingTxs) + prevChain, err := s.wallet.ChainSwitch(ctx, &s.sidechains, bestChain, matchingTxs) if err != nil { return err } @@ -1116,7 +1116,7 @@ func (s *Syncer) getHeaders(ctx context.Context, rp *p2p.RemotePeer) error { return err } - prevChain, err := s.wallet.ChainSwitch(&s.sidechains, bestChain, nil) + prevChain, err := s.wallet.ChainSwitch(ctx, &s.sidechains, bestChain, nil) if err != nil { s.sidechainMu.Unlock() return err diff --git a/ticketbuyer/go.mod b/ticketbuyer/go.mod index 6c8b7843b..ac3a75405 100644 --- a/ticketbuyer/go.mod +++ b/ticketbuyer/go.mod @@ -1,7 +1,7 @@ module github.com/decred/dcrwallet/ticketbuyer/v4 require ( - github.com/decred/dcrd/chaincfg/chainhash v1.0.1 + github.com/decred/dcrd/chaincfg/chainhash v1.0.2 github.com/decred/dcrd/dcrutil/v2 v2.0.0 github.com/decred/dcrwallet/errors v1.1.0 github.com/decred/dcrwallet/wallet/v3 v3.0.0-00010101000000-000000000000 diff --git a/ticketbuyer/go.sum b/ticketbuyer/go.sum index 00c9be035..fd3003c44 100644 --- a/ticketbuyer/go.sum +++ b/ticketbuyer/go.sum @@ -20,13 +20,22 @@ github.com/decred/base58 v1.0.0 h1:BVi1FQCThIjZ0ehG+I99NJ51o0xcc9A/fDKhmJxY6+w= github.com/decred/base58 v1.0.0/go.mod h1:LLY1p5e3g91byL/UO1eiZaYd+uRoVRarybgcoymu9Ks= github.com/decred/dcrd/blockchain v1.1.1 h1:CWr90sZ2YLQz84EGT+X/pzU+9AZB1eXQUy+4fsJSt5w= github.com/decred/dcrd/blockchain v1.1.1/go.mod h1:zxi/41LgzHitpz/CZu0gxHyFHz8+ysd3lH8E3P5Uifg= +github.com/decred/dcrd/blockchain v1.2.0 h1:XiNd8lsU3marW7Z9xwctaXYm/7xakWOla/ZYJIPIG9w= +github.com/decred/dcrd/blockchain v1.2.0/go.mod h1:U/cia18M3LOJjk30jYRIEJivI6wh8v+53+gANC2npA4= github.com/decred/dcrd/blockchain/stake v1.0.1 h1:IYGsNZRyMUsoFtVAUjd7XIccrIQ4YIqDeNzQJCjyS8A= github.com/decred/dcrd/blockchain/stake v1.0.1/go.mod h1:hgoGmWMIu2LLApBbcguVpzCEEfX7M2YhuMrQdpohJzc= github.com/decred/dcrd/blockchain/stake v1.0.2/go.mod h1:hgoGmWMIu2LLApBbcguVpzCEEfX7M2YhuMrQdpohJzc= github.com/decred/dcrd/blockchain/stake v1.1.0 h1:kCxZdQ2/UfcD+XjE3wlCv0vLKWR9ZFtjbbTTpudb74o= github.com/decred/dcrd/blockchain/stake v1.1.0/go.mod h1:WRuaml4bcyZYza1NT3qizlLcQwMIcAQRENvZVb2t884= +github.com/decred/dcrd/blockchain/stake v1.2.1 h1:Llj+mKNJEnMskeakMj62hllNVtiHF2vo7cDxsvoLVFg= +github.com/decred/dcrd/blockchain/stake v1.2.1/go.mod h1:3YGhsM2WCwUM6o0WLGoTCUXLOOw6H7tqXtVtWlcCE/Y= github.com/decred/dcrd/blockchain/stake/v2 v2.0.0 h1:+FMrSt5tPicBKlev0k/r/2VsaVwpIUcm1TPw69XgZw0= github.com/decred/dcrd/blockchain/stake/v2 v2.0.0/go.mod h1:jv/rKMcZ87lhvVkHot/tElxeAYEUJ3mnKPHJ7WPq86U= +github.com/decred/dcrd/blockchain/stake/v2 v2.0.1 h1:mAPZZA+Or8NPENheejmD6Fl90uykhurVuEdOBUMl35s= +github.com/decred/dcrd/blockchain/stake/v2 v2.0.1/go.mod h1:jv/rKMcZ87lhvVkHot/tElxeAYEUJ3mnKPHJ7WPq86U= +github.com/decred/dcrd/blockchain/standalone v1.0.0 h1:bPkFgSV7/NeZI+ZEGhaOP+XccCUBTIJb3YTf8dMwe8g= +github.com/decred/dcrd/blockchain/standalone v1.0.0/go.mod h1:U5lOleFSi1nL7heSdLgEtuvg0udS1p3cvHxvLJbihfE= +github.com/decred/dcrd/blockchain/v2 v2.0.2/go.mod h1:tAY/BejMCsa7ebIkyyhRefdQI35cFOMQ7B00x1+8vRQ= github.com/decred/dcrd/chaincfg v1.1.1 h1:qRZkiA7ucsfsQPE/G/U1OnEUFozDl1MvM4ysJCUndLU= github.com/decred/dcrd/chaincfg v1.1.1/go.mod h1:UlGtnp8Xx9YK+etBTybGjoFGoGXSw2bxZQuAnwfKv6I= github.com/decred/dcrd/chaincfg v1.2.0 h1:Vj0xr85wmqOdQDxKLkpP9TqwK1RykqY2eC0fWcCsl0k= @@ -38,14 +47,22 @@ github.com/decred/dcrd/chaincfg v1.5.2 h1:dd6l9rqcpxg2GF5neBmE2XxRc5Lqda45fWmN4X github.com/decred/dcrd/chaincfg v1.5.2/go.mod h1:FukMzTjkwzjPU+hK7CqDMQe3NMbSZAYU5PAcsx1wlv0= github.com/decred/dcrd/chaincfg/chainhash v1.0.1 h1:0vG7U9+dSjSCaHQKdoSKURK2pOb47+b+8FK5q4+Je7M= github.com/decred/dcrd/chaincfg/chainhash v1.0.1/go.mod h1:OVfvaOsNLS/A1y4Eod0Ip/Lf8qga7VXCQjUQLbkY0Go= +github.com/decred/dcrd/chaincfg/chainhash v1.0.2 h1:rt5Vlq/jM3ZawwiacWjPa+smINyLRN07EO0cNBV6DGU= +github.com/decred/dcrd/chaincfg/chainhash v1.0.2/go.mod h1:BpbrGgrPTr3YJYRN3Bm+D9NuaFd+zGyNeIKgrhCXK60= github.com/decred/dcrd/chaincfg/v2 v2.0.2 h1:VeGY52lHuYT01tIGbvYj+OO0GaGxGaJmnh+4vGca1+U= github.com/decred/dcrd/chaincfg/v2 v2.0.2/go.mod h1:hpKvhLCDAD/xDZ3V1Pqpv9fIKVYYi11DyxETguazyvg= github.com/decred/dcrd/chaincfg/v2 v2.1.0 h1:2S7TL9YWnKDDiH5bTpp3xcBo+1gl1IXFi5KU4QwSIDk= github.com/decred/dcrd/chaincfg/v2 v2.1.0/go.mod h1:hpKvhLCDAD/xDZ3V1Pqpv9fIKVYYi11DyxETguazyvg= +github.com/decred/dcrd/chaincfg/v2 v2.2.0 h1:SBkoqeM9+CkMA1V3i3Ffc4gAC4TqN2EoSRw5kjGkvx4= +github.com/decred/dcrd/chaincfg/v2 v2.2.0/go.mod h1:hpKvhLCDAD/xDZ3V1Pqpv9fIKVYYi11DyxETguazyvg= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/database v1.0.1 h1:BSIerNf4RhSA0iDhiE/320RYqD2y9T+SCj99Pv7svgo= github.com/decred/dcrd/database v1.0.1/go.mod h1:ILCeyOHFew3fZ7K2B9jl+tp5qFOap/pEGoo6Yy6Wk0g= github.com/decred/dcrd/database v1.0.3 h1:e5Q3gDt9LwfvpZxYqFF3OVzgr8bGeC1cen+V3mv/CCw= github.com/decred/dcrd/database v1.0.3/go.mod h1:TLxRwIV8x85+dxPTLAWu4mHg45TkKrrza5xzwOS1QtA= +github.com/decred/dcrd/database v1.1.0 h1:A9doThqEjOiE8NicDbMmRwr74itM47rcOzzWpy+keYU= +github.com/decred/dcrd/database v1.1.0/go.mod h1:/c8suHgDP20weTDFpObwvNbrMMlxn2LM4Tvm377ztwQ= github.com/decred/dcrd/database/v2 v2.0.0 h1:KWiyZHk+QyNKQvvxm/KpIejhTqYJqH9ssz1+9sT9nVA= github.com/decred/dcrd/database/v2 v2.0.0/go.mod h1:Sj2lvTRB0mfSu9uD7ObfwCY/eJ954GFU/X+AndJIyfE= github.com/decred/dcrd/dcrec v0.0.0-20180721005212-59fe2b293f69/go.mod h1:cRAH1SNk8Mi9hKBc/DHbeiWz/fyO8KWZR3H7okrIuOA= @@ -80,6 +97,7 @@ github.com/decred/dcrd/dcrutil v1.1.1 h1:zOkGiumN/JkobhAgpG/zfFgUoolGKVGYT5na1hb github.com/decred/dcrd/dcrutil v1.1.1/go.mod h1:Jsttr0pEvzPAw+qay1kS1/PsbZYPyhluiNwwY6yBJS4= github.com/decred/dcrd/dcrutil v1.2.0 h1:Pd5Wf650g6Xu6luYDfGkh1yiUoPUAgqzRu6K+BGyJGg= github.com/decred/dcrd/dcrutil v1.2.0/go.mod h1:tUNHS2gj7ApeEVS8gb6O+4wJW7w3O2MSRyRdcjW1JxU= +github.com/decred/dcrd/dcrutil v1.3.0/go.mod h1:7fUT70QAarhDwQK62g92uDbbYpjXlXngpy5RBiecufo= github.com/decred/dcrd/dcrutil v1.4.0 h1:xD5aUqysGQnsnP1c9J0kGeW8lDIwFGC3ja/gE3HnpCs= github.com/decred/dcrd/dcrutil v1.4.0/go.mod h1:Bs74gm1jQ9ZAbmEh9FWOEZ1HQzlMg5iPATDMzMnCMlQ= github.com/decred/dcrd/dcrutil/v2 v2.0.0 h1:HTqn2tZ8eqBF4y3hJwjyKBmJt16y7/HjzpE82E/crhY= @@ -88,14 +106,20 @@ github.com/decred/dcrd/gcs v1.0.1 h1:MpJXLskT41+JDaD3RLdlSlF2vlu1sxPpZgiRI7FVTWw github.com/decred/dcrd/gcs v1.0.1/go.mod h1:YwutGzusSdJM79CJtxCo9t7WRCvnkLtWSD19TPo1i9g= github.com/decred/dcrd/gcs v1.0.2 h1:wZjxeC9WPBoRApaAQpBrzvN9NA0iS2KWrTJa9IiDgc8= github.com/decred/dcrd/gcs v1.0.2/go.mod h1:eLCvrzUsWro48TlTyrmFcZAZqnllYFz0vEv5VZtufF4= +github.com/decred/dcrd/gcs v1.1.0 h1:djuYzaFUzUTJR+6ulMSRZOQ+P9rxtIyuxQeViAEfB8s= +github.com/decred/dcrd/gcs v1.1.0/go.mod h1:yBjhj217Vw5lw3aKnCdHip7fYb9zwMos8bCy5s79M9w= github.com/decred/dcrd/hdkeychain/v2 v2.0.0 h1:b6GklXT+LeDumc0bDqMHkss+p2Bu+mgiUDhjAX01LOc= github.com/decred/dcrd/hdkeychain/v2 v2.0.0/go.mod h1:tG+VpXfloIkNGHGd6NeoTElHWA68Wf1aP87zegXDGEw= +github.com/decred/dcrd/hdkeychain/v2 v2.0.1 h1:LnMLuPDx6j1/7ywGdfX5onPOsa98yObzBIJrp+nK4Qo= +github.com/decred/dcrd/hdkeychain/v2 v2.0.1/go.mod h1:qPv+vTla19liVHFuXVnQ70dMI4ERPCniDXbV5RzwQiM= github.com/decred/dcrd/rpc/jsonrpc/types v1.0.0 h1:d5ptnjuSADTQMa3i83VpeJNoMRTOJZZBqk7P+E41VXM= github.com/decred/dcrd/rpc/jsonrpc/types v1.0.0/go.mod h1:0dwmpIP21tJxjg/UuUHWIFMbfoLv2ifCBMokNKlOxpo= github.com/decred/dcrd/txscript v1.0.1 h1:IMgxZFCw3AyG4EbKwywE3SDNshOSHsoUK1Wk/5GqWJ0= github.com/decred/dcrd/txscript v1.0.1/go.mod h1:FqUX07Y+u3cJ1eIGPoyWbJg+Wk1NTllln/TyDpx9KnY= github.com/decred/dcrd/txscript v1.0.2 h1:kzJZDuteyzvI15VNhtgFHxeeq210RTkFyfzN7d+1iPo= github.com/decred/dcrd/txscript v1.0.2/go.mod h1:hmUOHFlOjU7H6T/czt6kurWwXJvGPGKKGtXoft6w/qY= +github.com/decred/dcrd/txscript v1.1.0 h1:MwkLXdc4Yq83oeNNEQJdlBTkNlorKXn8Nd5W2JXyMZg= +github.com/decred/dcrd/txscript v1.1.0/go.mod h1:gbcq6gpGfKddPmZSKp+17ils2cLzUqHopXf8H5rCY7Y= github.com/decred/dcrd/txscript/v2 v2.0.0 h1:So+NcQY58mDHDN2N2edED5syGZp2ed8Ltxj8mDE5CAs= github.com/decred/dcrd/txscript/v2 v2.0.0/go.mod h1:WStcyYYJa+PHJB4XjrLDRzV96/Z4thtsu8mZoVrU6C0= github.com/decred/dcrd/wire v1.1.0 h1:G+3CugtxNbToUN8RKWqm74yLfzJJ2BKMOr2RgWc4TyY= @@ -140,10 +164,13 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.1 h1:PZSj/UFNaVp3KxrzHOcS7oyuWA7LoOY/77yCTEFu21U= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= go.etcd.io/bbolt v1.3.2 h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= golang.org/x/crypto v0.0.0-20180718160520-a2144134853f h1:lRy+hhwk7YT7MsKejxuz0C5Q1gk6p/QoPQYEmKmGFb8= golang.org/x/crypto v0.0.0-20180718160520-a2144134853f/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -154,6 +181,7 @@ golang.org/x/net v0.0.0-20180719180050-a680a1efc54d h1:i6RB+Qz1ug7TvJdY4zieRMpnL golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180808004115-f9ce57c11b24 h1:mEsFm194MmS9vCwxFy+zwu0EU7ZkxxMD1iH++vmGdUY= golang.org/x/net v0.0.0-20180808004115-f9ce57c11b24/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= @@ -163,6 +191,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180816055513-1c9583448a9c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181206074257-70b957f3b65e h1:njOxP/wVblhCLIUhjHXf6X+dzTt5OQ3vMQo9mkOIKIo= golang.org/x/sys v0.0.0-20181206074257-70b957f3b65e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -180,3 +209,4 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/ticketbuyer/tb.go b/ticketbuyer/tb.go index 3e9f29c0a..17caff7c2 100644 --- a/ticketbuyer/tb.go +++ b/ticketbuyer/tb.go @@ -198,14 +198,14 @@ func (tb *TB) buy(ctx context.Context, passphrase []byte, tip *chainhash.Hash) e // Derive a voting address from voting account when address is unset. if votingAddr == nil { - votingAddr, err = w.NewInternalAddress(votingAccount, wallet.WithGapPolicyWrap()) + votingAddr, err = w.NewInternalAddress(ctx, votingAccount, wallet.WithGapPolicyWrap()) if err != nil { return err } } feeRate := w.RelayFee() - tix, err := w.PurchaseTickets(maintain, -1, minconf, votingAddr, account, + tix, err := w.PurchaseTickets(ctx, maintain, -1, minconf, votingAddr, account, buy, poolFeeAddr, poolFees, expiry, feeRate, feeRate) for _, hash := range tix { log.Infof("Purchased ticket %v at stake difficulty %v", hash, sdiff) diff --git a/wallet/addresses.go b/wallet/addresses.go index 8b4b316cd..30d535555 100644 --- a/wallet/addresses.go +++ b/wallet/addresses.go @@ -401,7 +401,7 @@ func (w *Wallet) deferPersistReturnedChild(updates *[]func(walletdb.ReadWriteTx) } // nextAddress returns the next address of an account branch. -func (w *Wallet) nextAddress(op errors.Op, persist persistReturnedChildFunc, account, branch uint32, +func (w *Wallet) nextAddress(ctx context.Context, op errors.Op, persist persistReturnedChildFunc, account, branch uint32, callOpts ...NextAddressCallOption) (dcrutil.Address, error) { var opts nextAddressCallOptions // TODO: zero values for now, add to wallet config later. @@ -453,7 +453,7 @@ func (w *Wallet) nextAddress(op errors.Op, persist persistReturnedChildFunc, acc if err != nil { return nil, errors.E(op, err) } - err = n.LoadTxFilter(context.TODO(), false, addrs, nil) + err = n.LoadTxFilter(ctx, false, addrs, nil) if err != nil { return nil, err } @@ -535,7 +535,7 @@ func (w *Wallet) markUsedAddress(op errors.Op, dbtx walletdb.ReadWriteTx, addr u return nil } -func (w *Wallet) watchFutureAddresses(dbtx walletdb.ReadTx) error { +func (w *Wallet) watchFutureAddresses(ctx context.Context, dbtx walletdb.ReadTx) error { const op errors.Op = "wallet.watchFutureAddresses" // TODO: There is room here for optimization. Improvements could be made by @@ -643,7 +643,7 @@ func (w *Wallet) watchFutureAddresses(dbtx walletdb.ReadTx) error { } go func() { - errs <- n.LoadTxFilter(context.TODO(), false, addrs, nil) + errs <- n.LoadTxFilter(ctx, false, addrs, nil) }() } @@ -657,18 +657,18 @@ func (w *Wallet) watchFutureAddresses(dbtx walletdb.ReadTx) error { } // NewExternalAddress returns an external address. -func (w *Wallet) NewExternalAddress(account uint32, callOpts ...NextAddressCallOption) (dcrutil.Address, error) { +func (w *Wallet) NewExternalAddress(ctx context.Context, account uint32, callOpts ...NextAddressCallOption) (dcrutil.Address, error) { const op errors.Op = "wallet.NewExternalAddress" - return w.nextAddress(op, w.persistReturnedChild(nil), account, udb.ExternalBranch, callOpts...) + return w.nextAddress(ctx, op, w.persistReturnedChild(nil), account, udb.ExternalBranch, callOpts...) } // NewInternalAddress returns an internal address. -func (w *Wallet) NewInternalAddress(account uint32, callOpts ...NextAddressCallOption) (dcrutil.Address, error) { +func (w *Wallet) NewInternalAddress(ctx context.Context, account uint32, callOpts ...NextAddressCallOption) (dcrutil.Address, error) { const op errors.Op = "wallet.NewExternalAddress" - return w.nextAddress(op, w.persistReturnedChild(nil), account, udb.InternalBranch, callOpts...) + return w.nextAddress(ctx, op, w.persistReturnedChild(nil), account, udb.InternalBranch, callOpts...) } -func (w *Wallet) newChangeAddress(op errors.Op, persist persistReturnedChildFunc, account uint32) (dcrutil.Address, error) { +func (w *Wallet) newChangeAddress(ctx context.Context, op errors.Op, persist persistReturnedChildFunc, account uint32) (dcrutil.Address, error) { // Addresses can not be generated for the imported account, so as a // workaround, change is sent to the first account. // @@ -676,16 +676,16 @@ func (w *Wallet) newChangeAddress(op errors.Op, persist persistReturnedChildFunc if account == udb.ImportedAddrAccount { account = udb.DefaultAccountNum } - return w.nextAddress(op, persist, account, udb.InternalBranch, WithGapPolicyWrap()) + return w.nextAddress(ctx, op, persist, account, udb.InternalBranch, WithGapPolicyWrap()) } // NewChangeAddress returns an internal address. This is identical to // NewInternalAddress but handles the imported account (which can't create // addresses) by using account 0 instead, and always uses the wrapping gap limit // policy. -func (w *Wallet) NewChangeAddress(account uint32) (dcrutil.Address, error) { +func (w *Wallet) NewChangeAddress(ctx context.Context, account uint32) (dcrutil.Address, error) { const op errors.Op = "wallet.NewChangeAddress" - return w.newChangeAddress(op, w.persistReturnedChild(nil), account) + return w.newChangeAddress(ctx, op, w.persistReturnedChild(nil), account) } // BIP0044BranchNextIndexes returns the next external and internal branch child @@ -708,7 +708,7 @@ func (w *Wallet) BIP0044BranchNextIndexes(account uint32) (extChild, intChild ui // ExtendWatchedAddresses derives and watches additional addresses for an // account branch they have not yet been derived. This does not modify the next // generated address for the branch. -func (w *Wallet) ExtendWatchedAddresses(account, branch, child uint32) error { +func (w *Wallet) ExtendWatchedAddresses(ctx context.Context, account, branch, child uint32) error { const op errors.Op = "wallet.ExtendWatchedAddresses" var ( @@ -762,7 +762,7 @@ func (w *Wallet) ExtendWatchedAddresses(account, branch, child uint32) error { if err != nil { return errors.E(op, err) } - err = n.LoadTxFilter(context.TODO(), false, addrs, nil) + err = n.LoadTxFilter(ctx, false, addrs, nil) if err != nil { return errors.E(op, err) } @@ -811,10 +811,11 @@ type p2PKHChangeSource struct { persist persistReturnedChildFunc account uint32 wallet *Wallet + ctx context.Context } func (src *p2PKHChangeSource) Script() ([]byte, uint16, error) { - changeAddress, err := src.wallet.newChangeAddress("", src.persist, src.account) + changeAddress, err := src.wallet.newChangeAddress(src.ctx, "", src.persist, src.account) if err != nil { return nil, 0, err } diff --git a/wallet/addresses_test.go b/wallet/addresses_test.go index 79b64cc42..6163c94e5 100644 --- a/wallet/addresses_test.go +++ b/wallet/addresses_test.go @@ -6,6 +6,7 @@ package wallet import ( "bytes" + "context" "encoding/hex" "io/ioutil" "os" @@ -186,7 +187,7 @@ func testExternalAddresses(tc *testContext) { } for i := 0; i < len(expectedExternalAddrs); i++ { - addr, err := w.NewExternalAddress(defaultAccount) + addr, err := w.NewExternalAddress(context.Background(), defaultAccount) if err != nil { tc.t.Fatalf("%s: failed to generate external address: %v", prefix, err) @@ -251,7 +252,7 @@ func testInternalAddresses(tc *testContext) { } for i := 0; i < len(expectedInternalAddrs); i++ { - addr, err := w.NewInternalAddress(defaultAccount) + addr, err := w.NewInternalAddress(context.Background(), defaultAccount) if err != nil { tc.t.Fatalf("%s: failed to generate internal address: %v", prefix, err) @@ -371,7 +372,7 @@ type accountIndexes [2]struct { func nextAddresses(n int) func(t *testing.T, w *Wallet) { return func(t *testing.T, w *Wallet) { for i := 0; i < n; i++ { - _, err := w.NewExternalAddress(0) + _, err := w.NewExternalAddress(context.Background(), 0) if err != nil { t.Fatal(err) } @@ -381,7 +382,7 @@ func nextAddresses(n int) func(t *testing.T, w *Wallet) { func watchFutureAddresses(t *testing.T, w *Wallet) { err := walletdb.View(w.db, func(dbtx walletdb.ReadTx) error { - return w.watchFutureAddresses(dbtx) + return w.watchFutureAddresses(context.Background(), dbtx) }) if err != nil { t.Fatal(err) diff --git a/wallet/chainntfns.go b/wallet/chainntfns.go index 4cb88c582..7990ef1f1 100644 --- a/wallet/chainntfns.go +++ b/wallet/chainntfns.go @@ -24,7 +24,8 @@ import ( "github.com/decred/dcrwallet/wallet/v3/walletdb" ) -func (w *Wallet) extendMainChain(op errors.Op, dbtx walletdb.ReadWriteTx, header *wire.BlockHeader, f *gcs.Filter, transactions []*wire.MsgTx) ([]wire.OutPoint, error) { +func (w *Wallet) extendMainChain(ctx context.Context, op errors.Op, dbtx walletdb.ReadWriteTx, + header *wire.BlockHeader, f *gcs.Filter, transactions []*wire.MsgTx) ([]wire.OutPoint, error) { txmgrNs := dbtx.ReadWriteBucket(wtxmgrNamespaceKey) blockHash := header.BlockHash() @@ -50,7 +51,7 @@ func (w *Wallet) extendMainChain(op errors.Op, dbtx walletdb.ReadWriteTx, header if err != nil { return nil, errors.E(op, err) } - ops, err := w.processTransactionRecord(dbtx, rec, header, &blockMeta) + ops, err := w.processTransactionRecord(ctx, dbtx, rec, header, &blockMeta) if err != nil { return nil, errors.E(op, err) } @@ -65,7 +66,7 @@ func (w *Wallet) extendMainChain(op errors.Op, dbtx walletdb.ReadWriteTx, header // blocks (if any) is returned. If relevantTxs is non-nil, the block marker for // the latest block with processed transactions is updated for the new tip // block. -func (w *Wallet) ChainSwitch(forest *SidechainForest, chain []*BlockNode, relevantTxs map[chainhash.Hash][]*wire.MsgTx) ([]*BlockNode, error) { +func (w *Wallet) ChainSwitch(ctx context.Context, forest *SidechainForest, chain []*BlockNode, relevantTxs map[chainhash.Hash][]*wire.MsgTx) ([]*BlockNode, error) { const op errors.Op = "wallet.ChainSwitch" if len(chain) == 0 { @@ -139,7 +140,7 @@ func (w *Wallet) ChainSwitch(forest *SidechainForest, chain []*BlockNode, releva "wallet to the latest version.", voteVersion(w.chainParams)) } - watch, err := w.extendMainChain(op, dbtx, n.Header, n.Filter, relevantTxs[*n.Hash]) + watch, err := w.extendMainChain(ctx, op, dbtx, n.Header, n.Filter, relevantTxs[*n.Hash]) if err != nil { return err } @@ -191,14 +192,14 @@ func (w *Wallet) ChainSwitch(forest *SidechainForest, chain []*BlockNode, releva } err = walletdb.View(w.db, func(tx walletdb.ReadTx) error { - return w.watchFutureAddresses(tx) + return w.watchFutureAddresses(ctx, tx) }) if err != nil && !errors.Is(errors.NoPeers, err) { return nil, err } if n, err := w.NetworkBackend(); err == nil && len(watchOutPoints) > 0 { - err := n.LoadTxFilter(context.TODO(), false, nil, watchOutPoints) + err := n.LoadTxFilter(ctx, false, nil, watchOutPoints) if err != nil { log.Errorf("Failed to watch outpoints: %v", err) } @@ -293,7 +294,7 @@ func (w *Wallet) evaluateStakePoolTicket(rec *udb.TxRecord, blockHeight int32, p // AcceptMempoolTx adds a relevant unmined transaction to the wallet. // If a network backend is associated with the wallet, it is updated // with new addresses and unspent outpoints to watch. -func (w *Wallet) AcceptMempoolTx(tx *wire.MsgTx) error { +func (w *Wallet) AcceptMempoolTx(ctx context.Context, tx *wire.MsgTx) error { const op errors.Op = "wallet.AcceptMempoolTx" var watchOutPoints []wire.OutPoint err := walletdb.Update(w.db, func(dbtx walletdb.ReadWriteTx) error { @@ -316,20 +317,20 @@ func (w *Wallet) AcceptMempoolTx(tx *wire.MsgTx) error { } } - watchOutPoints, err = w.processTransactionRecord(dbtx, rec, nil, nil) + watchOutPoints, err = w.processTransactionRecord(ctx, dbtx, rec, nil, nil) return err }) if err != nil { return errors.E(op, err) } err = walletdb.View(w.db, func(tx walletdb.ReadTx) error { - return w.watchFutureAddresses(tx) + return w.watchFutureAddresses(ctx, tx) }) if err != nil { log.Errorf("Failed to watch for future address usage: %v", err) } if n, err := w.NetworkBackend(); err == nil && len(watchOutPoints) > 0 { - err := n.LoadTxFilter(context.TODO(), false, nil, watchOutPoints) + err := n.LoadTxFilter(ctx, false, nil, watchOutPoints) if err != nil { log.Errorf("Failed to watch outpoints: %v", err) } @@ -337,7 +338,7 @@ func (w *Wallet) AcceptMempoolTx(tx *wire.MsgTx) error { return nil } -func (w *Wallet) processSerializedTransaction(dbtx walletdb.ReadWriteTx, serializedTx []byte, +func (w *Wallet) processSerializedTransaction(ctx context.Context, dbtx walletdb.ReadWriteTx, serializedTx []byte, header *wire.BlockHeader, blockMeta *udb.BlockMeta) (watchOutPoints []wire.OutPoint, err error) { const op errors.Op = "wallet.processSerializedTransaction" @@ -345,10 +346,10 @@ func (w *Wallet) processSerializedTransaction(dbtx walletdb.ReadWriteTx, seriali if err != nil { return nil, errors.E(op, err) } - return w.processTransactionRecord(dbtx, rec, header, blockMeta) + return w.processTransactionRecord(ctx, dbtx, rec, header, blockMeta) } -func (w *Wallet) processTransactionRecord(dbtx walletdb.ReadWriteTx, rec *udb.TxRecord, +func (w *Wallet) processTransactionRecord(ctx context.Context, dbtx walletdb.ReadWriteTx, rec *udb.TxRecord, header *wire.BlockHeader, blockMeta *udb.BlockMeta) (watchOutPoints []wire.OutPoint, err error) { const op errors.Op = "wallet.processTransactionRecord" @@ -566,7 +567,7 @@ func (w *Wallet) processTransactionRecord(dbtx walletdb.ReadWriteTx, rec *udb.Tx case err == nil: if n, err := w.NetworkBackend(); err == nil { addr := mscriptaddr.Address() - err := n.LoadTxFilter(context.TODO(), + err := n.LoadTxFilter(ctx, false, []dcrutil.Address{addr}, nil) if err != nil { return nil, errors.E(op, err) @@ -783,7 +784,7 @@ func selectOwnedTickets(w *Wallet, dbtx walletdb.ReadTx, tickets []*chainhash.Ha // vote is only valid when voting on the block described by the passed block // hash and height. When a network backend is associated with the wallet, // relevant commitment outputs are loaded as watched data. -func (w *Wallet) VoteOnOwnedTickets(winningTicketHashes []*chainhash.Hash, blockHash *chainhash.Hash, blockHeight int32) error { +func (w *Wallet) VoteOnOwnedTickets(ctx context.Context, winningTicketHashes []*chainhash.Hash, blockHash *chainhash.Hash, blockHeight int32) error { const op errors.Op = "wallet.VoteOnOwnedTickets" if !w.votingEnabled || blockHeight < int32(w.chainParams.StakeValidationHeight)-1 { @@ -881,7 +882,7 @@ func (w *Wallet) VoteOnOwnedTickets(winningTicketHashes []*chainhash.Hash, block var watchOutPoints []wire.OutPoint err = walletdb.Update(w.db, func(dbtx walletdb.ReadWriteTx) error { for i := range voteRecords { - watch, err := w.processTransactionRecord(dbtx, voteRecords[i], nil, nil) + watch, err := w.processTransactionRecord(ctx, dbtx, voteRecords[i], nil, nil) if err != nil { return err } @@ -895,7 +896,7 @@ func (w *Wallet) VoteOnOwnedTickets(winningTicketHashes []*chainhash.Hash, block // Publish before logging and handling any publishing errors to slightly // reduce latency. - err = n.PublishTransactions(context.TODO(), votes...) + err = n.PublishTransactions(ctx, votes...) for i := range voteRecords { log.Infof("Voting on block %v (height %v) using ticket %v "+ "(vote hash: %v bits: %v)", blockHash, blockHeight, @@ -917,7 +918,7 @@ func (w *Wallet) VoteOnOwnedTickets(winningTicketHashes []*chainhash.Hash, block } if len(watchOutPoints) > 0 { - err := n.LoadTxFilter(context.TODO(), false, nil, watchOutPoints) + err := n.LoadTxFilter(ctx, false, nil, watchOutPoints) if err != nil { log.Errorf("Failed to watch outpoints: %v", err) } @@ -930,7 +931,7 @@ func (w *Wallet) VoteOnOwnedTickets(winningTicketHashes []*chainhash.Hash, block // missedTicketHashes slice. When a network backend is associated // with the wallet, relevant commitment outputs are loaded as watched // data. -func (w *Wallet) RevokeOwnedTickets(missedTicketHashes []*chainhash.Hash) error { +func (w *Wallet) RevokeOwnedTickets(ctx context.Context, missedTicketHashes []*chainhash.Hash) error { const op errors.Op = "wallet.RevokeOwnedTickets" n, err := w.NetworkBackend() @@ -1021,7 +1022,7 @@ func (w *Wallet) RevokeOwnedTickets(missedTicketHashes []*chainhash.Hash) error var watchOutPoints []wire.OutPoint err = walletdb.Update(w.db, func(dbtx walletdb.ReadWriteTx) error { var err error - watchOutPoints, err = w.processTransactionRecord(dbtx, txRec, nil, nil) + watchOutPoints, err = w.processTransactionRecord(ctx, dbtx, txRec, nil, nil) return err }) if err != nil { @@ -1029,7 +1030,7 @@ func (w *Wallet) RevokeOwnedTickets(missedTicketHashes []*chainhash.Hash) error revocationHash, ticketHashes[i], err) continue } - err = n.PublishTransactions(context.TODO(), revocation) + err = n.PublishTransactions(ctx, revocation) if err != nil { log.Errorf("Failed to send revocation %v for ticket hash %v: %v", revocationHash, ticketHashes[i], err) @@ -1038,7 +1039,7 @@ func (w *Wallet) RevokeOwnedTickets(missedTicketHashes []*chainhash.Hash) error log.Infof("Revoked ticket %v with revocation %v", ticketHashes[i], revocationHash) if len(watchOutPoints) > 0 { - err := n.LoadTxFilter(context.TODO(), false, nil, watchOutPoints) + err := n.LoadTxFilter(ctx, false, nil, watchOutPoints) if err != nil { log.Errorf("Failed to watch outpoints: %v", err) } diff --git a/wallet/createtx.go b/wallet/createtx.go index 21d2b40be..ef0a560c1 100644 --- a/wallet/createtx.go +++ b/wallet/createtx.go @@ -306,7 +306,7 @@ func (w *Wallet) checkHighFees(totalInput dcrutil.Amount, tx *wire.MsgTx) error // txToOutputs creates a transaction, selecting previous outputs from an account // with no less than minconf confirmations, and creates a signed transaction // that pays to each of the outputs. -func (w *Wallet) txToOutputs(op errors.Op, outputs []*wire.TxOut, account uint32, +func (w *Wallet) txToOutputs(ctx context.Context, op errors.Op, outputs []*wire.TxOut, account uint32, minconf int32, randomizeChangeIdx bool) (*txauthor.AuthoredTx, error) { n, err := w.NetworkBackend() @@ -314,7 +314,7 @@ func (w *Wallet) txToOutputs(op errors.Op, outputs []*wire.TxOut, account uint32 return nil, errors.E(op, err) } - return w.txToOutputsInternal(op, outputs, account, minconf, n, + return w.txToOutputsInternal(ctx, op, outputs, account, minconf, n, randomizeChangeIdx, w.RelayFee()) } @@ -329,7 +329,7 @@ func (w *Wallet) txToOutputs(op errors.Op, outputs []*wire.TxOut, account uint32 // Decred: This func also sends the transaction, and if successful, inserts it // into the database, rather than delegating this work to the caller as // btcwallet does. -func (w *Wallet) txToOutputsInternal(op errors.Op, outputs []*wire.TxOut, account uint32, minconf int32, +func (w *Wallet) txToOutputsInternal(ctx context.Context, op errors.Op, outputs []*wire.TxOut, account uint32, minconf int32, n NetworkBackend, randomizeChangeIdx bool, txFee dcrutil.Amount) (*txauthor.AuthoredTx, error) { var unlockOutpoints []*wire.OutPoint @@ -365,6 +365,7 @@ func (w *Wallet) txToOutputsInternal(op errors.Op, outputs []*wire.TxOut, accoun persist: w.deferPersistReturnedChild(&changeSourceUpdates), account: account, wallet: w, + ctx: ctx, } var err error atx, err = txauthor.NewUnsignedTransaction(outputs, txFee, @@ -436,27 +437,27 @@ func (w *Wallet) txToOutputsInternal(op errors.Op, outputs []*wire.TxOut, accoun // TODO: this can be improved by not using the same codepath as notified // relevant transactions, since this does a lot of extra work. var err error - watch, err = w.processTransactionRecord(dbtx, rec, nil, nil) + watch, err = w.processTransactionRecord(ctx, dbtx, rec, nil, nil) return err }) if err != nil { return nil, errors.E(op, err) } - err = n.PublishTransactions(context.TODO(), atx.Tx) + err = n.PublishTransactions(ctx, atx.Tx) if err != nil { return nil, errors.E(op, err) } // Watch for future relevant transactions. err = walletdb.View(w.db, func(dbtx walletdb.ReadTx) error { - return w.watchFutureAddresses(dbtx) + return w.watchFutureAddresses(ctx, dbtx) }) if err != nil { log.Errorf("Failed to watch for future address usage after publishing "+ "transaction: %v", err) } if len(watch) > 0 { - err := n.LoadTxFilter(context.TODO(), false, nil, watch) + err := n.LoadTxFilter(ctx, false, nil, watch) if err != nil { log.Errorf("Failed to watch outpoints: %v", err) } @@ -466,27 +467,27 @@ func (w *Wallet) txToOutputsInternal(op errors.Op, outputs []*wire.TxOut, accoun // txToMultisig spends funds to a multisig output, partially signs the // transaction, then returns fund -func (w *Wallet) txToMultisig(op errors.Op, account uint32, amount dcrutil.Amount, pubkeys []*dcrutil.AddressSecpPubKey, +func (w *Wallet) txToMultisig(ctx context.Context, op errors.Op, account uint32, amount dcrutil.Amount, pubkeys []*dcrutil.AddressSecpPubKey, nRequired int8, minconf int32) (*CreatedTx, dcrutil.Address, []byte, error) { var ( - ctx *CreatedTx + created *CreatedTx addr dcrutil.Address msScript []byte ) err := walletdb.Update(w.db, func(dbtx walletdb.ReadWriteTx) error { var err error - ctx, addr, msScript, err = w.txToMultisigInternal(op, dbtx, + created, addr, msScript, err = w.txToMultisigInternal(ctx, op, dbtx, account, amount, pubkeys, nRequired, minconf) return err }) if err != nil { return nil, nil, nil, errors.E(op, err) } - return ctx, addr, msScript, nil + return created, addr, msScript, nil } -func (w *Wallet) txToMultisigInternal(op errors.Op, dbtx walletdb.ReadWriteTx, account uint32, amount dcrutil.Amount, +func (w *Wallet) txToMultisigInternal(ctx context.Context, op errors.Op, dbtx walletdb.ReadWriteTx, account uint32, amount dcrutil.Amount, pubkeys []*dcrutil.AddressSecpPubKey, nRequired int8, minconf int32) (*CreatedTx, dcrutil.Address, []byte, error) { addrmgrNs := dbtx.ReadWriteBucket(waddrmgrNamespaceKey) @@ -591,6 +592,7 @@ func (w *Wallet) txToMultisigInternal(op errors.Op, dbtx walletdb.ReadWriteTx, a persist: w.persistReturnedChild(dbtx), account: account, wallet: w, + ctx: ctx, } pkScript, _, err := changeSource.Script() @@ -611,14 +613,14 @@ func (w *Wallet) txToMultisigInternal(op errors.Op, dbtx walletdb.ReadWriteTx, a return txToMultisigError(errors.E(op, err)) } - err = n.PublishTransactions(context.TODO(), msgtx) + err = n.PublishTransactions(ctx, msgtx) if err != nil { return txToMultisigError(errors.E(op, err)) } // Request updates from dcrd for new transactions sent to this // script hash address. - err = n.LoadTxFilter(context.TODO(), false, []dcrutil.Address{scAddr}, nil) + err = n.LoadTxFilter(ctx, false, []dcrutil.Address{scAddr}, nil) if err != nil { return txToMultisigError(errors.E(op, err)) } @@ -628,13 +630,13 @@ func (w *Wallet) txToMultisigInternal(op errors.Op, dbtx walletdb.ReadWriteTx, a return txToMultisigError(errors.E(op, err)) } - ctx := &CreatedTx{ + created := &CreatedTx{ MsgTx: msgtx, ChangeAddr: nil, ChangeIndex: -1, } - return ctx, scAddr, msScript, nil + return created, scAddr, msScript, nil } // validateMsgTx verifies transaction input scripts for tx. All previous output @@ -670,11 +672,11 @@ func creditScripts(credits []udb.Credit) [][]byte { // compressWallet compresses all the utxos in a wallet into a single change // address. For use when it becomes dusty. -func (w *Wallet) compressWallet(op errors.Op, maxNumIns int, account uint32, changeAddr dcrutil.Address) (*chainhash.Hash, error) { +func (w *Wallet) compressWallet(ctx context.Context, op errors.Op, maxNumIns int, account uint32, changeAddr dcrutil.Address) (*chainhash.Hash, error) { var hash *chainhash.Hash err := walletdb.Update(w.db, func(dbtx walletdb.ReadWriteTx) error { var err error - hash, err = w.compressWalletInternal(op, dbtx, maxNumIns, account, changeAddr) + hash, err = w.compressWalletInternal(ctx, op, dbtx, maxNumIns, account, changeAddr) return err }) if err != nil { @@ -683,7 +685,7 @@ func (w *Wallet) compressWallet(op errors.Op, maxNumIns int, account uint32, cha return hash, nil } -func (w *Wallet) compressWalletInternal(op errors.Op, dbtx walletdb.ReadWriteTx, maxNumIns int, account uint32, +func (w *Wallet) compressWalletInternal(ctx context.Context, op errors.Op, dbtx walletdb.ReadWriteTx, maxNumIns int, account uint32, changeAddr dcrutil.Address) (*chainhash.Hash, error) { addrmgrNs := dbtx.ReadWriteBucket(waddrmgrNamespaceKey) @@ -709,7 +711,7 @@ func (w *Wallet) compressWalletInternal(op errors.Op, dbtx walletdb.ReadWriteTx, // Check if output address is default, and generate a new address if needed if changeAddr == nil { - changeAddr, err = w.newChangeAddress(op, w.persistReturnedChild(dbtx), account) + changeAddr, err = w.newChangeAddress(ctx, op, w.persistReturnedChild(dbtx), account) if err != nil { return nil, errors.E(op, err) } @@ -772,7 +774,7 @@ func (w *Wallet) compressWalletInternal(op errors.Op, dbtx walletdb.ReadWriteTx, return nil, errors.E(op, err) } - err = n.PublishTransactions(context.TODO(), msgtx) + err = n.PublishTransactions(ctx, msgtx) if err != nil { return nil, errors.E(op, err) } @@ -964,7 +966,7 @@ func (w *Wallet) purchaseTickets(ctx context.Context, op errors.Op, n NetworkBac if err != nil { err = errors.E(op, err) } - addrFunc = func(errors.Op, persistReturnedChildFunc, uint32) (dcrutil.Address, error) { + addrFunc = func(context.Context, errors.Op, persistReturnedChildFunc, uint32) (dcrutil.Address, error) { return addr, err } } @@ -1106,7 +1108,7 @@ func (w *Wallet) purchaseTickets(ctx context.Context, op errors.Op, n NetworkBac // immediately be consumed as tickets. // // This opens a write transaction. - splitTxAddr, err := w.NewInternalAddress(req.SourceAccount, WithGapPolicyWrap()) + splitTxAddr, err := w.NewInternalAddress(ctx, req.SourceAccount, WithGapPolicyWrap()) if err != nil { return nil, err } @@ -1156,7 +1158,7 @@ func (w *Wallet) purchaseTickets(ctx context.Context, op errors.Op, n NetworkBac if txFeeIncrement == 0 { txFeeIncrement = w.RelayFee() } - splitTx, err := w.txToOutputsInternal(op, splitOuts, account, req.MinConf, + splitTx, err := w.txToOutputsInternal(ctx, op, splitOuts, account, req.MinConf, n, false, txFeeIncrement) if err != nil { return nil, err @@ -1167,7 +1169,7 @@ func (w *Wallet) purchaseTickets(ctx context.Context, op errors.Op, n NetworkBac var watchOutPoints []wire.OutPoint defer func() { err := walletdb.View(w.db, func(tx walletdb.ReadTx) error { - return w.watchFutureAddresses(tx) + return w.watchFutureAddresses(ctx, tx) }) if err != nil { log.Errorf("Failed to watch for future addresses after ticket "+ @@ -1239,14 +1241,14 @@ func (w *Wallet) purchaseTickets(ctx context.Context, op errors.Op, n NetworkBac if addrVote == nil { addrVote = w.ticketAddress if addrVote == nil { - addrVote, err = addrFunc(op, w.persistReturnedChild(dbtx), req.SourceAccount) + addrVote, err = addrFunc(ctx, op, w.persistReturnedChild(dbtx), req.SourceAccount) if err != nil { return err } } } - addrSubsidy, err = addrFunc(op, w.persistReturnedChild(dbtx), req.SourceAccount) + addrSubsidy, err = addrFunc(ctx, op, w.persistReturnedChild(dbtx), req.SourceAccount) return err }) if err != nil { @@ -1307,7 +1309,7 @@ func (w *Wallet) purchaseTickets(ctx context.Context, op errors.Op, n NetworkBac } err = walletdb.Update(w.db, func(dbtx walletdb.ReadWriteTx) error { - watch, err := w.processTransactionRecord(dbtx, rec, nil, nil) + watch, err := w.processTransactionRecord(ctx, dbtx, rec, nil, nil) watchOutPoints = append(watchOutPoints, watch...) return err }) diff --git a/wallet/reorg_test.go b/wallet/reorg_test.go index 582885ce2..bac3cf195 100644 --- a/wallet/reorg_test.go +++ b/wallet/reorg_test.go @@ -5,6 +5,7 @@ package wallet import ( + "context" "fmt" "testing" @@ -91,7 +92,7 @@ func (tw *tw) assertNoBetterChain(forest *SidechainForest) { } func (tw *tw) chainSwitch(forest *SidechainForest, chain []*BlockNode) { - prevChain, err := tw.ChainSwitch(forest, chain, nil) + prevChain, err := tw.ChainSwitch(context.Background(), forest, chain, nil) if err != nil { tw.Fatal(err) } diff --git a/wallet/rescan.go b/wallet/rescan.go index ca417baf4..306473a15 100644 --- a/wallet/rescan.go +++ b/wallet/rescan.go @@ -180,7 +180,7 @@ func (w *Wallet) SaveRescanned(hash *chainhash.Hash, txs []*wire.MsgTx) error { if err != nil { return err } - _, err = w.processTransactionRecord(dbtx, rec, header, &blockMeta) + _, err = w.processTransactionRecord(context.Background(), dbtx, rec, header, &blockMeta) if err != nil { return err } diff --git a/wallet/tickets.go b/wallet/tickets.go index a7c8234ff..1c18274a2 100644 --- a/wallet/tickets.go +++ b/wallet/tickets.go @@ -356,7 +356,7 @@ func (w *Wallet) RevokeTickets(ctx context.Context, rpcCaller Caller) error { err = walletdb.Update(w.db, func(dbtx walletdb.ReadWriteTx) error { // Could be more efficient by avoiding processTransaction, as we // know it is a revocation. - watch, err = w.processTransactionRecord(dbtx, rec, nil, nil) + watch, err = w.processTransactionRecord(ctx, dbtx, rec, nil, nil) if err != nil { return errors.E(op, err) } @@ -467,7 +467,7 @@ func (w *Wallet) RevokeExpiredTickets(ctx context.Context, p Peer) (err error) { log.Infof("Revoking ticket %v with revocation %v", &expired[i], &rec.Hash) - watch, err := w.processTransactionRecord(dbtx, rec, nil, nil) + watch, err := w.processTransactionRecord(ctx, dbtx, rec, nil, nil) if err != nil { return err } diff --git a/wallet/wallet.go b/wallet/wallet.go index b4248bbe1..ce70cc920 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -1028,7 +1028,7 @@ func (w *Wallet) fetchHeaders(ctx context.Context, op errors.Op, p Peer) (firstN } } for _, n := range chain { - _, err = w.extendMainChain("", dbtx, n.Header, n.Filter, nil) + _, err = w.extendMainChain(ctx, "", dbtx, n.Header, n.Filter, nil) if err != nil { return err } @@ -1080,30 +1080,32 @@ func (w *Wallet) FetchHeaders(ctx context.Context, p Peer) (count int, rescanFro // Consolidate consolidates as many UTXOs as are passed in the inputs argument. // If that many UTXOs can not be found, it will use the maximum it finds. This // will only compress UTXOs in the default account -func (w *Wallet) Consolidate(inputs int, account uint32, address dcrutil.Address) (*chainhash.Hash, error) { +func (w *Wallet) Consolidate(ctx context.Context, inputs int, account uint32, address dcrutil.Address) (*chainhash.Hash, error) { heldUnlock, err := w.holdUnlock() if err != nil { return nil, err } defer heldUnlock.release() - return w.compressWallet("wallet.Consolidate", inputs, account, address) + return w.compressWallet(ctx, "wallet.Consolidate", inputs, account, address) } // CreateMultisigTx creates and signs a multisig transaction. -func (w *Wallet) CreateMultisigTx(account uint32, amount dcrutil.Amount, pubkeys []*dcrutil.AddressSecpPubKey, nrequired int8, minconf int32) (*CreatedTx, dcrutil.Address, []byte, error) { +func (w *Wallet) CreateMultisigTx(ctx context.Context, account uint32, amount dcrutil.Amount, + pubkeys []*dcrutil.AddressSecpPubKey, nrequired int8, minconf int32) (*CreatedTx, dcrutil.Address, []byte, error) { heldUnlock, err := w.holdUnlock() if err != nil { return nil, nil, nil, err } defer heldUnlock.release() - return w.txToMultisig("wallet.CreateMultisigTx", account, amount, pubkeys, nrequired, minconf) + return w.txToMultisig(ctx, "wallet.CreateMultisigTx", account, amount, pubkeys, nrequired, minconf) } // PurchaseTickets purchases tickets, returning the hashes of all ticket // purchase transactions. // // Deprecated: Use PurchaseTicketsContext for solo buying. -func (w *Wallet) PurchaseTickets(minBalance, spendLimit dcrutil.Amount, minConf int32, votingAddr dcrutil.Address, account uint32, count int, poolAddress dcrutil.Address, +func (w *Wallet) PurchaseTickets(ctx context.Context, minBalance, spendLimit dcrutil.Amount, minConf int32, + votingAddr dcrutil.Address, account uint32, count int, poolAddress dcrutil.Address, poolFees float64, expiry int32, txFee dcrutil.Amount, ticketFee dcrutil.Amount) ([]*chainhash.Hash, error) { const op errors.Op = "wallet.PurchaseTickets" @@ -1134,7 +1136,7 @@ func (w *Wallet) PurchaseTickets(minBalance, spendLimit dcrutil.Amount, minConf } defer heldUnlock.release() - return w.purchaseTickets(context.Background(), op, n, req) + return w.purchaseTickets(ctx, op, n, req) } // PurchaseTicketsRequest describes the parameters for purchasing tickets. @@ -1614,7 +1616,7 @@ func (w *Wallet) RenameAccount(account uint32, newName string) error { // restoring, new accounts may not be created when all of the previous 100 // accounts have no transaction history (this is a deviation from the BIP0044 // spec, which allows no unused account gaps). -func (w *Wallet) NextAccount(name string) (uint32, error) { +func (w *Wallet) NextAccount(ctx context.Context, name string) (uint32, error) { const op errors.Op = "wallet.NextAccount" maxEmptyAccounts := uint32(w.accountGapLimit) var account uint32 @@ -1701,7 +1703,7 @@ func (w *Wallet) NextAccount(name string) (uint32, error) { errs <- err return } - errs <- n.LoadTxFilter(context.TODO(), false, addrs, nil) + errs <- n.LoadTxFilter(ctx, false, addrs, nil) }() } for i := 0; i < cap(errs); i++ { @@ -3080,7 +3082,7 @@ func (w *Wallet) DumpWIFPrivateKey(addr dcrutil.Address) (string, error) { // ImportPrivateKey imports a private key to the wallet and writes the new // wallet to disk. -func (w *Wallet) ImportPrivateKey(wif *dcrutil.WIF) (string, error) { +func (w *Wallet) ImportPrivateKey(ctx context.Context, wif *dcrutil.WIF) (string, error) { const op errors.Op = "wallet.ImportPrivateKey" // Attempt to import private key into wallet. var addr dcrutil.Address @@ -3100,7 +3102,7 @@ func (w *Wallet) ImportPrivateKey(wif *dcrutil.WIF) (string, error) { } if n, err := w.NetworkBackend(); err == nil { - err := n.LoadTxFilter(context.TODO(), false, []dcrutil.Address{addr}, nil) + err := n.LoadTxFilter(ctx, false, []dcrutil.Address{addr}, nil) if err != nil { return "", errors.E(op, err) } @@ -3118,7 +3120,7 @@ func (w *Wallet) ImportPrivateKey(wif *dcrutil.WIF) (string, error) { // ImportScript imports a redeemscript to the wallet. If it also allows the // user to specify whether or not they want the redeemscript to be rescanned, // and how far back they wish to rescan. -func (w *Wallet) ImportScript(rs []byte) error { +func (w *Wallet) ImportScript(ctx context.Context, rs []byte) error { const op errors.Op = "wallet.ImportScript" err := walletdb.Update(w.db, func(tx walletdb.ReadWriteTx) error { addrmgrNs := tx.ReadWriteBucket(waddrmgrNamespaceKey) @@ -3146,7 +3148,7 @@ func (w *Wallet) ImportScript(rs []byte) error { addr := mscriptaddr.Address() if n, err := w.NetworkBackend(); err == nil { - err := n.LoadTxFilter(context.TODO(), false, []dcrutil.Address{addr}, nil) + err := n.LoadTxFilter(ctx, false, []dcrutil.Address{addr}, nil) if err != nil { return err } @@ -3752,7 +3754,7 @@ func (w *Wallet) TotalReceivedForAddr(addr dcrutil.Address, minConf int32) (dcru // SendOutputs creates and sends payment transactions. It returns the // transaction hash upon success -func (w *Wallet) SendOutputs(outputs []*wire.TxOut, account uint32, minconf int32) (*chainhash.Hash, error) { +func (w *Wallet) SendOutputs(ctx context.Context, outputs []*wire.TxOut, account uint32, minconf int32) (*chainhash.Hash, error) { const op errors.Op = "wallet.SendOutputs" relayFee := w.RelayFee() for _, output := range outputs { @@ -3767,7 +3769,7 @@ func (w *Wallet) SendOutputs(outputs []*wire.TxOut, account uint32, minconf int3 return nil, err } defer heldUnlock.release() - tx, err := w.txToOutputs("wallet.SendOutputs", outputs, account, minconf, true) + tx, err := w.txToOutputs(ctx, "wallet.SendOutputs", outputs, account, minconf, true) if err != nil { return nil, err } @@ -4075,7 +4077,7 @@ func (w *Wallet) AbandonTransaction(hash *chainhash.Hash) error { // PublishTransaction saves (if relevant) and sends the transaction to the // consensus RPC server so it can be propagated to other nodes and eventually // mined. If the send fails, the transaction is not added to the wallet. -func (w *Wallet) PublishTransaction(tx *wire.MsgTx, serializedTx []byte, n NetworkBackend) (*chainhash.Hash, error) { +func (w *Wallet) PublishTransaction(ctx context.Context, tx *wire.MsgTx, serializedTx []byte, n NetworkBackend) (*chainhash.Hash, error) { const opf = "wallet.PublishTransaction(%v)" txHash := tx.TxHash() @@ -4111,7 +4113,7 @@ func (w *Wallet) PublishTransaction(tx *wire.MsgTx, serializedTx []byte, n Netwo if err != nil { return err } - watchOutPoints, err = w.processTransactionRecord(dbtx, rec, nil, nil) + watchOutPoints, err = w.processTransactionRecord(ctx, dbtx, rec, nil, nil) return err }) if err != nil { @@ -4120,7 +4122,7 @@ func (w *Wallet) PublishTransaction(tx *wire.MsgTx, serializedTx []byte, n Netwo } } - err = n.PublishTransactions(context.TODO(), tx) + err = n.PublishTransactions(ctx, tx) if err != nil { // Return the error and purge relevant txs from the store only if the // backend returns an error different than "already have transaction". @@ -4162,7 +4164,7 @@ func (w *Wallet) PublishTransaction(tx *wire.MsgTx, serializedTx []byte, n Netwo } if len(watchOutPoints) > 0 { - err := n.LoadTxFilter(context.TODO(), false, nil, watchOutPoints) + err := n.LoadTxFilter(ctx, false, nil, watchOutPoints) if err != nil { log.Errorf("Failed to watch outpoints: %v", err) }