chainntnfs/btcdnotify: add chainParams parameter to btcdnotify.New

In this commit, we add the current chain parameters to the BtcdNotifier.
This will be used in a future commit in order to convert outputs scripts
into addresses. This is needed since the btcd backend uses these
addresses to detect whether the script encoded within it was spent by a
transaction in the chain.
This commit is contained in:
Wilmer Paulino committed 2019-01-21 13:57:43 -08:00
1 parent 7f644019b8
commit 1ee8d7518c
3 files changed
+23 -11

No files matched your search

+7 -2
View File
@@ -9,6 +9,7 @@ import (
"time"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/wire"
@@ -64,7 +65,8 @@ type BtcdNotifier struct {
started int32 // To be used atomically.
stopped int32 // To be used atomically.
chainConn *rpcclient.Client
chainConn *rpcclient.Client
chainParams *chaincfg.Params
notificationCancels chan interface{}
notificationRegistry chan interface{}
@@ -98,10 +100,13 @@ var _ chainntnfs.ChainNotifier = (*BtcdNotifier)(nil)
// New returns a new BtcdNotifier instance. This function assumes the btcd node
// detailed in the passed configuration is already running, and willing to
// accept new websockets clients.
func New(config *rpcclient.ConnConfig, spendHintCache chainntnfs.SpendHintCache,
func New(config *rpcclient.ConnConfig, chainParams *chaincfg.Params,
spendHintCache chainntnfs.SpendHintCache,
confirmHintCache chainntnfs.ConfirmHintCache) (*BtcdNotifier, error) {
notifier := &BtcdNotifier{
chainParams: chainParams,
notificationCancels: make(chan interface{}),
notificationRegistry: make(chan interface{}),