multi: update btcsuite API's to latest upstream changes

This commit makes a large number of minor changes concerning API usage
within the deamon to match the latest version on the upstream btcsuite
libraries.

The major changes are the switch from wire.ShaHash to chainhash.Hash,
and that wire.NewMsgTx() now takes a paramter indicating the version of
the transaction to be created.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-01-05 13:56:34 -08:00
1 parent 5d37c1d9e7
commit 5affed38fc
40 files changed
+234 -211

No files matched your search

+3 -2
View File
@@ -11,6 +11,7 @@ import (
"github.com/boltdb/bolt"
"github.com/lightningnetwork/lnd/elkrem"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
)
@@ -1274,7 +1275,7 @@ func fetchChanCommitTxns(nodeChanBucket *bolt.Bucket, channel *OpenChannel) erro
txnBytes := bytes.NewReader(nodeChanBucket.Get(txnsKey))
channel.OurCommitTx = wire.NewMsgTx()
channel.OurCommitTx = wire.NewMsgTx(2)
if err = channel.OurCommitTx.Deserialize(txnBytes); err != nil {
return err
}
@@ -1502,7 +1503,7 @@ func fetchChanElkremState(nodeChanBucket *bolt.Bucket, channel *OpenChannel) err
if err != nil {
return err
}
elkremRoot, err := wire.NewShaHash(senderBytes)
elkremRoot, err := chainhash.NewHash(senderBytes)
if err != nil {
return err
}
+6 -5
View File
@@ -12,6 +12,7 @@ import (
"github.com/lightningnetwork/lnd/elkrem"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/txscript"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
@@ -19,16 +20,16 @@ import (
)
var (
netParams = &chaincfg.SegNet4Params
netParams = &chaincfg.TestNet3Params
key = [wire.HashSize]byte{
key = [chainhash.HashSize]byte{
0x81, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
0x68, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
0xd, 0xe7, 0x93, 0xe4, 0xb7, 0x25, 0xb8, 0x4d,
0x1e, 0xb, 0x4c, 0xf9, 0x9e, 0xc5, 0x8c, 0xe9,
}
id = &wire.OutPoint{
Hash: [wire.HashSize]byte{
Hash: [chainhash.HashSize]byte{
0x51, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
0x48, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
0x2d, 0xe7, 0x93, 0xe4, 0xb7, 0x25, 0xb8, 0x4d,
@@ -36,7 +37,7 @@ var (
},
Index: 9,
}
rev = [wire.HashSize]byte{
rev = [chainhash.HashSize]byte{
0x51, 0xb6, 0x37, 0xd8, 0xfc, 0xd2, 0xc6, 0xda,
0x48, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
0x2d, 0xe7, 0x93, 0xe4,
@@ -46,7 +47,7 @@ var (
TxIn: []*wire.TxIn{
&wire.TxIn{
PreviousOutPoint: wire.OutPoint{
Hash: wire.ShaHash{},
Hash: chainhash.Hash{},
Index: 0xffffffff,
},
SignatureScript: []byte{0x04, 0x31, 0xdc, 0x00, 0x1b, 0x01, 0x62},
+4 -3
View File
@@ -10,6 +10,7 @@ import (
"github.com/boltdb/bolt"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
)
@@ -505,7 +506,7 @@ const (
// with the current UTXO state. An integer is returned which reflects the
// number of channels pruned due to the new incoming block.
func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
blockHash *wire.ShaHash, blockHeight uint32) (uint32, error) {
blockHash *chainhash.Hash, blockHeight uint32) (uint32, error) {
var numChans uint32
@@ -572,10 +573,10 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
// used to prune channels in the graph. Knowing the "prune tip" allows callers
// to tell if the graph is currently in sync with the current best known UTXO
// state.
func (c *ChannelGraph) PruneTip() (*wire.ShaHash, uint32, error) {
func (c *ChannelGraph) PruneTip() (*chainhash.Hash, uint32, error) {
var (
currentTip [pruneTipBytes]byte
tipHash wire.ShaHash
tipHash chainhash.Hash
tipHeight uint32
)
+3 -2
View File
@@ -13,6 +13,7 @@ import (
"github.com/btcsuite/fastsha256"
"github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/wire"
"github.com/roasbeef/btcutil"
)
@@ -524,7 +525,7 @@ func TestGraphTraversal(t *testing.T) {
}
}
func assertPruneTip(t *testing.T, graph *ChannelGraph, blockHash *wire.ShaHash,
func assertPruneTip(t *testing.T, graph *ChannelGraph, blockHash *chainhash.Hash,
blockHeight uint32) {
pruneHash, pruneHeight, err := graph.PruneTip()
@@ -629,7 +630,7 @@ func TestGraphPruning(t *testing.T) {
// First we create a mock block that ends up closing the first two
// channels.
var blockHash wire.ShaHash
var blockHash chainhash.Hash
copy(blockHash[:], bytes.Repeat([]byte{1}, 32))
blockHeight := uint32(1)
block := channelPoints[:2]