From 99ac1f566751278ebf9c1bc6ca1a2a4761c03842 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Thu, 23 Apr 2015 13:51:31 -0500 Subject: [PATCH] btcjson: Remove NewOutPointFromWire and wire dep. This commit removes the NewOutPointFromWire function from the btcjson version 2 package so it can be used without needing the wire package as a dependency. It also updates the test accordingly. This results in the package only depending on core Go packages. Closes #401. --- btcjson/v2/btcjson/chainsvrwscmds.go | 13 ------------- btcjson/v2/btcjson/chainsvrwscmds_test.go | 8 ++++---- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/btcjson/v2/btcjson/chainsvrwscmds.go b/btcjson/v2/btcjson/chainsvrwscmds.go index aae31d38..7409d0d1 100644 --- a/btcjson/v2/btcjson/chainsvrwscmds.go +++ b/btcjson/v2/btcjson/chainsvrwscmds.go @@ -7,10 +7,6 @@ package btcjson -import ( - "github.com/btcsuite/btcd/wire" -) - // AuthenticateCmd defines the authenticate JSON-RPC command. type AuthenticateCmd struct { Username string @@ -71,15 +67,6 @@ type OutPoint struct { Index uint32 `json:"index"` } -// NewOutPointFromWire creates a new OutPoint from the OutPoint structure -// of the btcwire package. -func NewOutPointFromWire(op *wire.OutPoint) *OutPoint { - return &OutPoint{ - Hash: op.Hash.String(), - Index: op.Index, - } -} - // NotifySpentCmd defines the notifyspent JSON-RPC command. type NotifySpentCmd struct { OutPoints []OutPoint diff --git a/btcjson/v2/btcjson/chainsvrwscmds_test.go b/btcjson/v2/btcjson/chainsvrwscmds_test.go index 6f9c18e3..32f7bfa1 100644 --- a/btcjson/v2/btcjson/chainsvrwscmds_test.go +++ b/btcjson/v2/btcjson/chainsvrwscmds_test.go @@ -12,7 +12,6 @@ import ( "testing" "github.com/btcsuite/btcd/btcjson/v2/btcjson" - "github.com/btcsuite/btcd/wire" ) // TestChainSvrWsCmds tests all of the chain server websocket-specific commands @@ -112,9 +111,10 @@ func TestChainSvrWsCmds(t *testing.T) { }, staticCmd: func() interface{} { addrs := []string{"1Address"} - hash, _ := wire.NewShaHashFromStr("123") - op := wire.NewOutPoint(hash, 0) - ops := []btcjson.OutPoint{*btcjson.NewOutPointFromWire(op)} + ops := []btcjson.OutPoint{{ + Hash: "0000000000000000000000000000000000000000000000000000000000000123", + Index: 0, + }} return btcjson.NewRescanCmd("123", addrs, ops, nil) }, marshalled: `{"jsonrpc":"1.0","method":"rescan","params":["123",["1Address"],[{"hash":"0000000000000000000000000000000000000000000000000000000000000123","index":0}]],"id":1}`,