diff --git a/README.md b/README.md index ca8b011c..44413649 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ monad [![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/monasuite/monad) -monad is an alternative full node monacoin implementation written in Go (golang). +monad is an alternative full node bitcoin implementation written in Go (golang). This project is currently under active development and is in a Beta state. It is extremely stable and has been in production use since October 2013. @@ -25,7 +25,7 @@ ensures all individual transactions admitted to the pool follow the rules required by the block chain and also includes more strict checks which filter transactions based on miner requirements ("standard" transactions). -One key difference between monad and Monacoin Core is that monad does *NOT* include +One key difference between monad and Bitcoin Core is that monad does *NOT* include wallet functionality and this was a very intentional design decision. See the blog entry [here](https://web.archive.org/web/20171125143919/https://blog.conformal.com/btcd-not-your-moms-bitcoin-daemon) for more details. This means you can't actually make or receive payments @@ -104,6 +104,12 @@ Launch monad from your Start menu. $ ./monad ``` +## IRC + +- irc.freenode.net +- channel #monad +- [webchat](https://webchat.freenode.net/?channels=monad) + ## Issue Tracker The [integrated github issue tracker](https://github.com/monasuite/monad/issues) diff --git a/btcjson/chainsvrcmds.go b/btcjson/chainsvrcmds.go index 701af3a6..9c313e75 100644 --- a/btcjson/chainsvrcmds.go +++ b/btcjson/chainsvrcmds.go @@ -13,7 +13,6 @@ import ( "fmt" "github.com/monasuite/monad/wire" - "github.com/shopspring/decimal" ) // AddNodeSubCmd defines the type used in the addnode JSON-RPC command for the @@ -58,7 +57,7 @@ type TransactionInput struct { // CreateRawTransactionCmd defines the createrawtransaction JSON-RPC command. type CreateRawTransactionCmd struct { Inputs []TransactionInput - Amounts map[string]decimal.Decimal `jsonrpcusage:"{\"address\":amount,...}"` // In BTC + Amounts map[string]float64 `jsonrpcusage:"{\"address\":amount,...}"` // In BTC LockTime *int64 } @@ -119,7 +118,7 @@ func NewDumpVolatileCheckpointCmd() *DumpVolatileCheckpointCmd { // // Amounts are in BTC. Passing in nil and the empty slice as inputs is equivalent, // both gets interpreted as the empty slice. -func NewCreateRawTransactionCmd(inputs []TransactionInput, amounts map[string]decimal.Decimal, +func NewCreateRawTransactionCmd(inputs []TransactionInput, amounts map[string]float64, lockTime *int64) *CreateRawTransactionCmd { // to make sure we're serializing this to the empty list and not null, we // explicitly initialize the list @@ -1032,9 +1031,9 @@ func init() { MustRegisterCmd("checkpoint", (*CheckpointCmd)(nil), flags) MustRegisterCmd("dumpcheckpoint", (*DumpCheckpointCmd)(nil), flags) MustRegisterCmd("dumpvolatilecheckpoint", (*DumpVolatileCheckpointCmd)(nil), flags) - MustRegisterCmd("fundrawtransaction", (*FundRawTransactionCmd)(nil), flags) MustRegisterCmd("decoderawtransaction", (*DecodeRawTransactionCmd)(nil), flags) MustRegisterCmd("decodescript", (*DecodeScriptCmd)(nil), flags) + MustRegisterCmd("fundrawtransaction", (*FundRawTransactionCmd)(nil), flags) MustRegisterCmd("getaddednodeinfo", (*GetAddedNodeInfoCmd)(nil), flags) MustRegisterCmd("getbestblockhash", (*GetBestBlockHashCmd)(nil), flags) MustRegisterCmd("getblock", (*GetBlockCmd)(nil), flags) diff --git a/btcjson/chainsvrcmds_test.go b/btcjson/chainsvrcmds_test.go index 6f5e2a13..2d8abc34 100644 --- a/btcjson/chainsvrcmds_test.go +++ b/btcjson/chainsvrcmds_test.go @@ -14,7 +14,6 @@ import ( "github.com/monasuite/monad/btcjson" "github.com/monasuite/monad/wire" - "github.com/shopspring/decimal" ) // TestChainSvrCmds tests all of the chain server commands marshal and unmarshal @@ -53,28 +52,28 @@ func TestChainSvrCmds(t *testing.T) { txInputs := []btcjson.TransactionInput{ {Txid: "123", Vout: 1}, } - amounts := map[string]decimal.Decimal{"456": decimal.NewFromFloat(.0123)} + amounts := map[string]float64{"456": .0123} return btcjson.NewCreateRawTransactionCmd(txInputs, amounts, nil) }, - marshalled: `{"jsonrpc":"1.0","method":"createrawtransaction","params":[[{"txid":"123","vout":1}],{"456":"0.0123"}],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"createrawtransaction","params":[[{"txid":"123","vout":1}],{"456":0.0123}],"id":1}`, unmarshalled: &btcjson.CreateRawTransactionCmd{ Inputs: []btcjson.TransactionInput{{Txid: "123", Vout: 1}}, - Amounts: map[string]decimal.Decimal{"456": decimal.NewFromFloat(.0123)}, + Amounts: map[string]float64{"456": .0123}, }, }, { name: "createrawtransaction - no inputs", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("createrawtransaction", `[]`, `{"456":"0.0123"}`) + return btcjson.NewCmd("createrawtransaction", `[]`, `{"456":0.0123}`) }, staticCmd: func() interface{} { - amounts := map[string]decimal.Decimal{"456": decimal.NewFromFloat(.0123)} + amounts := map[string]float64{"456": .0123} return btcjson.NewCreateRawTransactionCmd(nil, amounts, nil) }, - marshalled: `{"jsonrpc":"1.0","method":"createrawtransaction","params":[[],{"456":"0.0123"}],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"createrawtransaction","params":[[],{"456":0.0123}],"id":1}`, unmarshalled: &btcjson.CreateRawTransactionCmd{ Inputs: []btcjson.TransactionInput{}, - Amounts: map[string]decimal.Decimal{"456": decimal.NewFromFloat(.0123)}, + Amounts: map[string]float64{"456": .0123}, }, }, { @@ -87,13 +86,13 @@ func TestChainSvrCmds(t *testing.T) { txInputs := []btcjson.TransactionInput{ {Txid: "123", Vout: 1}, } - amounts := map[string]decimal.Decimal{"456": decimal.NewFromFloat(.0123)} + amounts := map[string]float64{"456": .0123} return btcjson.NewCreateRawTransactionCmd(txInputs, amounts, btcjson.Int64(12312333333)) }, - marshalled: `{"jsonrpc":"1.0","method":"createrawtransaction","params":[[{"txid":"123","vout":1}],{"456":"0.0123"},12312333333],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"createrawtransaction","params":[[{"txid":"123","vout":1}],{"456":0.0123},12312333333],"id":1}`, unmarshalled: &btcjson.CreateRawTransactionCmd{ Inputs: []btcjson.TransactionInput{{Txid: "123", Vout: 1}}, - Amounts: map[string]decimal.Decimal{"456": decimal.NewFromFloat(.0123)}, + Amounts: map[string]float64{"456": .0123}, LockTime: btcjson.Int64(12312333333), }, }, diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go index 011fa1c1..3759eb0c 100644 --- a/btcjson/chainsvrresults.go +++ b/btcjson/chainsvrresults.go @@ -438,7 +438,6 @@ type GetTxOutResult struct { BestBlock string `json:"bestblock"` Confirmations int64 `json:"confirmations"` Value float64 `json:"value"` - Amount monautil.Amount `json:"amount"` ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"` Coinbase bool `json:"coinbase"` } @@ -529,9 +528,8 @@ func (v *Vin) MarshalJSON() ([]byte, error) { // PrevOut represents previous output for an input Vin. type PrevOut struct { - Addresses []string `json:"addresses,omitempty"` - Value float64 `json:"value"` - Amount monautil.Amount `json:"amount"` + Addresses []string `json:"addresses,omitempty"` + Value float64 `json:"value"` } // VinPrevOut is like Vin except it includes PrevOut. It is used by searchrawtransaction @@ -608,7 +606,6 @@ func (v *VinPrevOut) MarshalJSON() ([]byte, error) { // getrawtransaction and decoderawtransaction use the same structure. type Vout struct { Value float64 `json:"value"` - Amount monautil.Amount `json:"amount"` N uint32 `json:"n"` ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"` } diff --git a/btcjson/chainsvrresults_test.go b/btcjson/chainsvrresults_test.go index 805e9408..23884ab2 100644 --- a/btcjson/chainsvrresults_test.go +++ b/btcjson/chainsvrresults_test.go @@ -66,7 +66,7 @@ func TestChainSvrCustomResults(t *testing.T) { }, Sequence: 4294967295, }, - expected: `{"txid":"123","vout":1,"scriptSig":{"asm":"0","hex":"00"},"prevOut":{"addresses":["addr1"],"value":0,"amount":0},"sequence":4294967295}`, + expected: `{"txid":"123","vout":1,"scriptSig":{"asm":"0","hex":"00"},"prevOut":{"addresses":["addr1"],"value":0},"sequence":4294967295}`, }, } diff --git a/btcjson/chainsvrwsntfns.go b/btcjson/chainsvrwsntfns.go index 053ddd78..58b7a544 100644 --- a/btcjson/chainsvrwsntfns.go +++ b/btcjson/chainsvrwsntfns.go @@ -8,8 +8,6 @@ package btcjson -import "github.com/shopspring/decimal" - const ( // BlockConnectedNtfnMethod is the legacy, deprecated method used for // notifications from the chain server that a block has been connected. @@ -250,12 +248,12 @@ func NewRescanProgressNtfn(hash string, height int32, time int64) *RescanProgres // TxAcceptedNtfn defines the txaccepted JSON-RPC notification. type TxAcceptedNtfn struct { TxID string - Amount decimal.Decimal + Amount float64 } // NewTxAcceptedNtfn returns a new instance which can be used to issue a // txaccepted JSON-RPC notification. -func NewTxAcceptedNtfn(txHash string, amount decimal.Decimal) *TxAcceptedNtfn { +func NewTxAcceptedNtfn(txHash string, amount float64) *TxAcceptedNtfn { return &TxAcceptedNtfn{ TxID: txHash, Amount: amount, diff --git a/btcjson/chainsvrwsntfns_test.go b/btcjson/chainsvrwsntfns_test.go index be47b144..223dfbc8 100644 --- a/btcjson/chainsvrwsntfns_test.go +++ b/btcjson/chainsvrwsntfns_test.go @@ -13,7 +13,6 @@ import ( "testing" "github.com/monasuite/monad/btcjson" - "github.com/shopspring/decimal" ) // TestChainSvrWsNtfns tests all of the chain server websocket-specific @@ -172,15 +171,15 @@ func TestChainSvrWsNtfns(t *testing.T) { { name: "txaccepted", newNtfn: func() (interface{}, error) { - return btcjson.NewCmd("txaccepted", "123", decimal.NewFromFloat(1.5)) + return btcjson.NewCmd("txaccepted", "123", 1.5) }, staticNtfn: func() interface{} { - return btcjson.NewTxAcceptedNtfn("123", decimal.NewFromFloat(1.5)) + return btcjson.NewTxAcceptedNtfn("123", 1.5) }, - marshalled: `{"jsonrpc":"1.0","method":"txaccepted","params":["123","1.5"],"id":null}`, + marshalled: `{"jsonrpc":"1.0","method":"txaccepted","params":["123",1.5],"id":null}`, unmarshalled: &btcjson.TxAcceptedNtfn{ TxID: "123", - Amount: decimal.NewFromFloat(1.5), + Amount: 1.5, }, }, { diff --git a/btcjson/cmdinfo.go b/btcjson/cmdinfo.go index cbcb844a..1e78e286 100644 --- a/btcjson/cmdinfo.go +++ b/btcjson/cmdinfo.go @@ -72,8 +72,6 @@ func subStructUsage(structType reflect.Type) string { fieldValue := fieldName fieldKind := rtf.Type.Kind() switch { - case fieldKind.String() == "decimal.Decimal": - fieldValue = "n.nnn" case isNumeric(fieldKind): if fieldKind == reflect.Float32 || fieldKind == reflect.Float64 { fieldValue = "n.nnn" @@ -152,9 +150,6 @@ func fieldUsage(structField reflect.StructField, defaultVal *reflect.Value) stri // Handle certain types uniquely to provide nicer usage. fieldName := strings.ToLower(structField.Name) - if fieldType.String() == "decimal.Decimal" { - return fieldName - } switch fieldType.Kind() { case reflect.String: if defaultVal != nil { diff --git a/btcjson/help.go b/btcjson/help.go index 2a7e11a0..f502d09f 100644 --- a/btcjson/help.go +++ b/btcjson/help.go @@ -48,9 +48,6 @@ type descLookupFunc func(string) string // associated with the provided Go type. func reflectTypeToJSONType(xT descLookupFunc, rt reflect.Type) string { kind := rt.Kind() - if rt.String() == "decimal.Decimal" { - return xT("json-type-numeric") - } if isNumeric(kind) { return xT("json-type-numeric") } @@ -148,9 +145,6 @@ func reflectTypeToJSONExample(xT descLookupFunc, rt reflect.Type, indentLevel in if rt.Kind() == reflect.Ptr { rt = rt.Elem() } - if rt.String() == "decimal.Decimal" { - return []string{"n.nnn"}, false - } kind := rt.Kind() if isNumeric(kind) { if kind == reflect.Float32 || kind == reflect.Float64 { @@ -338,6 +332,7 @@ func argHelp(xT descLookupFunc, rtp reflect.Type, defaults map[int]reflect.Value if numFields == 0 { return "" } + // Generate the help for each argument in the command. Several // simplifying assumptions are made here because the RegisterCmd // function has already rigorously enforced the layout. @@ -348,11 +343,13 @@ func argHelp(xT descLookupFunc, rtp reflect.Type, defaults map[int]reflect.Value if defVal, ok := defaults[i]; ok { defaultVal = &defVal } + fieldName := strings.ToLower(rtf.Name) helpText := fmt.Sprintf("%d.\t%s\t(%s)\t%s", i+1, fieldName, argTypeHelp(xT, rtf, defaultVal), xT(method+"-"+fieldName)) args = append(args, helpText) + // For types which require a JSON object, or an array of JSON // objects, generate the full syntax for the argument. fieldType := rtf.Type @@ -362,11 +359,9 @@ func argHelp(xT descLookupFunc, rtp reflect.Type, defaults map[int]reflect.Value kind := fieldType.Kind() switch kind { case reflect.Struct: - if fieldType.String() != "decimal.Decimal" { - fieldDescKey := fmt.Sprintf("%s-%s", method, fieldName) - resultText := resultTypeHelp(xT, fieldType, fieldDescKey) - args = append(args, resultText) - } + fieldDescKey := fmt.Sprintf("%s-%s", method, fieldName) + resultText := resultTypeHelp(xT, fieldType, fieldDescKey) + args = append(args, resultText) case reflect.Map: fieldDescKey := fmt.Sprintf("%s-%s", method, fieldName) @@ -451,9 +446,6 @@ func isValidResultType(kind reflect.Kind) bool { if isNumeric(kind) { return true } - if kind.String() == "decimal.Decimal" { - return true - } switch kind { case reflect.String, reflect.Struct, reflect.Array, reflect.Slice, @@ -558,6 +550,7 @@ func GenerateHelp(method string, descs map[string]string, resultTypes ...interfa missingKey = key return key } + // Generate and return the help for the method. help := methodHelp(xT, rtp, info.defaults, method, resultTypes) if missingKey != "" { diff --git a/btcjson/helpers.go b/btcjson/helpers.go index 90fe1fbe..eda26cb8 100644 --- a/btcjson/helpers.go +++ b/btcjson/helpers.go @@ -4,8 +4,6 @@ package btcjson -import "github.com/shopspring/decimal" - // Bool is a helper routine that allocates a new bool value to store v and // returns a pointer to it. This is useful when assigning optional parameters. func Bool(v bool) *bool { @@ -78,14 +76,6 @@ func String(v string) *string { return p } -// Decimal is a helper routine that allocates a new decimal.Decimal value to store v and -// returns a pointer to it. This is useful when assigning optional parameters. -func Decimal(v decimal.Decimal) *decimal.Decimal { - p := new(decimal.Decimal) - *p = v - return p -} - // NewFilterTypeName is a helper routine that allocates a new FilterTypeName value to store v and // returns a pointer to it. This is useful when assigning optional parameters. func NewFilterTypeName(v FilterTypeName) *FilterTypeName { diff --git a/btcjson/helpers_test.go b/btcjson/helpers_test.go index 45221a71..61a5de14 100644 --- a/btcjson/helpers_test.go +++ b/btcjson/helpers_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/monasuite/monad/btcjson" - "github.com/shopspring/decimal" ) // TestHelpers tests the various helper functions which create pointers to @@ -102,16 +101,6 @@ func TestHelpers(t *testing.T) { return &val }(), }, - { - name: "decimal", - f: func() interface{} { - return btcjson.Decimal(decimal.NewFromFloat(0.0001)) - }, - expected: func() interface{} { - val := decimal.NewFromFloat(0.0001) - return &val - }(), - }, } t.Logf("Running %d tests", len(tests)) diff --git a/btcjson/walletsvrcmds.go b/btcjson/walletsvrcmds.go index 8f783d5b..a2c73988 100644 --- a/btcjson/walletsvrcmds.go +++ b/btcjson/walletsvrcmds.go @@ -10,8 +10,6 @@ package btcjson import ( "encoding/json" "fmt" - - "github.com/shopspring/decimal" ) // AddMultisigAddressCmd defines the addmutisigaddress JSON-RPC command. @@ -490,8 +488,8 @@ func NewLockUnspentCmd(unlock bool, transactions []TransactionInput) *LockUnspen type MoveCmd struct { FromAccount string ToAccount string - Amount decimal.Decimal // In BTC - MinConf *int `jsonrpcdefault:"1"` + Amount float64 // In BTC + MinConf *int `jsonrpcdefault:"1"` Comment *string } @@ -500,7 +498,7 @@ type MoveCmd struct { // // The parameters which are pointers indicate they are optional. Passing nil // for optional parameters will use the default value. -func NewMoveCmd(fromAccount, toAccount string, amount decimal.Decimal, minConf *int, comment *string) *MoveCmd { +func NewMoveCmd(fromAccount, toAccount string, amount float64, minConf *int, comment *string) *MoveCmd { return &MoveCmd{ FromAccount: fromAccount, ToAccount: toAccount, @@ -514,8 +512,8 @@ func NewMoveCmd(fromAccount, toAccount string, amount decimal.Decimal, minConf * type SendFromCmd struct { FromAccount string ToAddress string - Amount decimal.Decimal // In BTC - MinConf *int `jsonrpcdefault:"1"` + Amount float64 // In BTC + MinConf *int `jsonrpcdefault:"1"` Comment *string CommentTo *string } @@ -525,7 +523,7 @@ type SendFromCmd struct { // // The parameters which are pointers indicate they are optional. Passing nil // for optional parameters will use the default value. -func NewSendFromCmd(fromAccount, toAddress string, amount decimal.Decimal, minConf *int, comment, commentTo *string) *SendFromCmd { +func NewSendFromCmd(fromAccount, toAddress string, amount float64, minConf *int, comment, commentTo *string) *SendFromCmd { return &SendFromCmd{ FromAccount: fromAccount, ToAddress: toAddress, @@ -539,8 +537,8 @@ func NewSendFromCmd(fromAccount, toAddress string, amount decimal.Decimal, minCo // SendManyCmd defines the sendmany JSON-RPC command. type SendManyCmd struct { FromAccount string - Amounts map[string]decimal.Decimal `jsonrpcusage:"{\"address\":amount,...}"` // In BTC - MinConf *int `jsonrpcdefault:"1"` + Amounts map[string]float64 `jsonrpcusage:"{\"address\":amount,...}"` // In BTC + MinConf *int `jsonrpcdefault:"1"` Comment *string } @@ -549,7 +547,7 @@ type SendManyCmd struct { // // The parameters which are pointers indicate they are optional. Passing nil // for optional parameters will use the default value. -func NewSendManyCmd(fromAccount string, amounts map[string]decimal.Decimal, minConf *int, comment *string) *SendManyCmd { +func NewSendManyCmd(fromAccount string, amounts map[string]float64, minConf *int, comment *string) *SendManyCmd { return &SendManyCmd{ FromAccount: fromAccount, Amounts: amounts, @@ -561,7 +559,7 @@ func NewSendManyCmd(fromAccount string, amounts map[string]decimal.Decimal, minC // SendToAddressCmd defines the sendtoaddress JSON-RPC command. type SendToAddressCmd struct { Address string - Amount decimal.Decimal + Amount float64 Comment *string CommentTo *string } @@ -571,7 +569,7 @@ type SendToAddressCmd struct { // // The parameters which are pointers indicate they are optional. Passing nil // for optional parameters will use the default value. -func NewSendToAddressCmd(address string, amount decimal.Decimal, comment, commentTo *string) *SendToAddressCmd { +func NewSendToAddressCmd(address string, amount float64, comment, commentTo *string) *SendToAddressCmd { return &SendToAddressCmd{ Address: address, Amount: amount, @@ -597,12 +595,12 @@ func NewSetAccountCmd(address, account string) *SetAccountCmd { // SetTxFeeCmd defines the settxfee JSON-RPC command. type SetTxFeeCmd struct { - Amount decimal.Decimal // In BTC + Amount float64 // In BTC } // NewSetTxFeeCmd returns a new instance which can be used to issue a settxfee // JSON-RPC command. -func NewSetTxFeeCmd(amount decimal.Decimal) *SetTxFeeCmd { +func NewSetTxFeeCmd(amount float64) *SetTxFeeCmd { return &SetTxFeeCmd{ Amount: amount, } diff --git a/btcjson/walletsvrcmds_test.go b/btcjson/walletsvrcmds_test.go index 8ae33540..f4b8100f 100644 --- a/btcjson/walletsvrcmds_test.go +++ b/btcjson/walletsvrcmds_test.go @@ -12,7 +12,6 @@ import ( "testing" "github.com/monasuite/monad/btcjson" - "github.com/shopspring/decimal" ) // TestWalletSvrCmds tests all of the wallet server commands marshal and @@ -873,16 +872,16 @@ func TestWalletSvrCmds(t *testing.T) { { name: "move", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("move", "from", "to", decimal.NewFromFloat(0.5)) + return btcjson.NewCmd("move", "from", "to", 0.5) }, staticCmd: func() interface{} { - return btcjson.NewMoveCmd("from", "to", decimal.NewFromFloat(0.5), nil, nil) + return btcjson.NewMoveCmd("from", "to", 0.5, nil, nil) }, - marshalled: `{"jsonrpc":"1.0","method":"move","params":["from","to","0.5"],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"move","params":["from","to",0.5],"id":1}`, unmarshalled: &btcjson.MoveCmd{ FromAccount: "from", ToAccount: "to", - Amount: decimal.NewFromFloat(0.5), + Amount: 0.5, MinConf: btcjson.Int(1), Comment: nil, }, @@ -890,16 +889,16 @@ func TestWalletSvrCmds(t *testing.T) { { name: "move optional1", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("move", "from", "to", decimal.NewFromFloat(0.5), 6) + return btcjson.NewCmd("move", "from", "to", 0.5, 6) }, staticCmd: func() interface{} { - return btcjson.NewMoveCmd("from", "to", decimal.NewFromFloat(0.5), btcjson.Int(6), nil) + return btcjson.NewMoveCmd("from", "to", 0.5, btcjson.Int(6), nil) }, - marshalled: `{"jsonrpc":"1.0","method":"move","params":["from","to","0.5",6],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"move","params":["from","to",0.5,6],"id":1}`, unmarshalled: &btcjson.MoveCmd{ FromAccount: "from", ToAccount: "to", - Amount: decimal.NewFromFloat(0.5), + Amount: 0.5, MinConf: btcjson.Int(6), Comment: nil, }, @@ -907,16 +906,16 @@ func TestWalletSvrCmds(t *testing.T) { { name: "move optional2", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("move", "from", "to", decimal.NewFromFloat(0.5), 6, "comment") + return btcjson.NewCmd("move", "from", "to", 0.5, 6, "comment") }, staticCmd: func() interface{} { - return btcjson.NewMoveCmd("from", "to", decimal.NewFromFloat(0.5), btcjson.Int(6), btcjson.String("comment")) + return btcjson.NewMoveCmd("from", "to", 0.5, btcjson.Int(6), btcjson.String("comment")) }, - marshalled: `{"jsonrpc":"1.0","method":"move","params":["from","to","0.5",6,"comment"],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"move","params":["from","to",0.5,6,"comment"],"id":1}`, unmarshalled: &btcjson.MoveCmd{ FromAccount: "from", ToAccount: "to", - Amount: decimal.NewFromFloat(0.5), + Amount: 0.5, MinConf: btcjson.Int(6), Comment: btcjson.String("comment"), }, @@ -924,16 +923,16 @@ func TestWalletSvrCmds(t *testing.T) { { name: "sendfrom", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("sendfrom", "from", "1Address", decimal.NewFromFloat(0.5)) + return btcjson.NewCmd("sendfrom", "from", "1Address", 0.5) }, staticCmd: func() interface{} { - return btcjson.NewSendFromCmd("from", "1Address", decimal.NewFromFloat(0.5), nil, nil, nil) + return btcjson.NewSendFromCmd("from", "1Address", 0.5, nil, nil, nil) }, - marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address","0.5"],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address",0.5],"id":1}`, unmarshalled: &btcjson.SendFromCmd{ FromAccount: "from", ToAddress: "1Address", - Amount: decimal.NewFromFloat(0.5), + Amount: 0.5, MinConf: btcjson.Int(1), Comment: nil, CommentTo: nil, @@ -942,16 +941,16 @@ func TestWalletSvrCmds(t *testing.T) { { name: "sendfrom optional1", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("sendfrom", "from", "1Address", decimal.NewFromFloat(0.5), 6) + return btcjson.NewCmd("sendfrom", "from", "1Address", 0.5, 6) }, staticCmd: func() interface{} { - return btcjson.NewSendFromCmd("from", "1Address", decimal.NewFromFloat(0.5), btcjson.Int(6), nil, nil) + return btcjson.NewSendFromCmd("from", "1Address", 0.5, btcjson.Int(6), nil, nil) }, - marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address","0.5",6],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address",0.5,6],"id":1}`, unmarshalled: &btcjson.SendFromCmd{ FromAccount: "from", ToAddress: "1Address", - Amount: decimal.NewFromFloat(0.5), + Amount: 0.5, MinConf: btcjson.Int(6), Comment: nil, CommentTo: nil, @@ -960,17 +959,17 @@ func TestWalletSvrCmds(t *testing.T) { { name: "sendfrom optional2", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("sendfrom", "from", "1Address", decimal.NewFromFloat(0.5), 6, "comment") + return btcjson.NewCmd("sendfrom", "from", "1Address", 0.5, 6, "comment") }, staticCmd: func() interface{} { - return btcjson.NewSendFromCmd("from", "1Address", decimal.NewFromFloat(0.5), btcjson.Int(6), + return btcjson.NewSendFromCmd("from", "1Address", 0.5, btcjson.Int(6), btcjson.String("comment"), nil) }, - marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address","0.5",6,"comment"],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address",0.5,6,"comment"],"id":1}`, unmarshalled: &btcjson.SendFromCmd{ FromAccount: "from", ToAddress: "1Address", - Amount: decimal.NewFromFloat(0.5), + Amount: 0.5, MinConf: btcjson.Int(6), Comment: btcjson.String("comment"), CommentTo: nil, @@ -979,17 +978,17 @@ func TestWalletSvrCmds(t *testing.T) { { name: "sendfrom optional3", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("sendfrom", "from", "1Address", decimal.NewFromFloat(0.5), 6, "comment", "commentto") + return btcjson.NewCmd("sendfrom", "from", "1Address", 0.5, 6, "comment", "commentto") }, staticCmd: func() interface{} { - return btcjson.NewSendFromCmd("from", "1Address", decimal.NewFromFloat(0.5), btcjson.Int(6), + return btcjson.NewSendFromCmd("from", "1Address", 0.5, btcjson.Int(6), btcjson.String("comment"), btcjson.String("commentto")) }, - marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address","0.5",6,"comment","commentto"],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"sendfrom","params":["from","1Address",0.5,6,"comment","commentto"],"id":1}`, unmarshalled: &btcjson.SendFromCmd{ FromAccount: "from", ToAddress: "1Address", - Amount: decimal.NewFromFloat(0.5), + Amount: 0.5, MinConf: btcjson.Int(6), Comment: btcjson.String("comment"), CommentTo: btcjson.String("commentto"), @@ -1001,13 +1000,13 @@ func TestWalletSvrCmds(t *testing.T) { return btcjson.NewCmd("sendmany", "from", `{"1Address":0.5}`) }, staticCmd: func() interface{} { - amounts := map[string]decimal.Decimal{"1Address": decimal.NewFromFloat(0.5)} + amounts := map[string]float64{"1Address": 0.5} return btcjson.NewSendManyCmd("from", amounts, nil, nil) }, - marshalled: `{"jsonrpc":"1.0","method":"sendmany","params":["from",{"1Address":"0.5"}],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"sendmany","params":["from",{"1Address":0.5}],"id":1}`, unmarshalled: &btcjson.SendManyCmd{ FromAccount: "from", - Amounts: map[string]decimal.Decimal{"1Address": decimal.NewFromFloat(0.5)}, + Amounts: map[string]float64{"1Address": 0.5}, MinConf: btcjson.Int(1), Comment: nil, }, @@ -1018,13 +1017,13 @@ func TestWalletSvrCmds(t *testing.T) { return btcjson.NewCmd("sendmany", "from", `{"1Address":0.5}`, 6) }, staticCmd: func() interface{} { - amounts := map[string]decimal.Decimal{"1Address": decimal.NewFromFloat(0.5)} + amounts := map[string]float64{"1Address": 0.5} return btcjson.NewSendManyCmd("from", amounts, btcjson.Int(6), nil) }, - marshalled: `{"jsonrpc":"1.0","method":"sendmany","params":["from",{"1Address":"0.5"},6],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"sendmany","params":["from",{"1Address":0.5},6],"id":1}`, unmarshalled: &btcjson.SendManyCmd{ FromAccount: "from", - Amounts: map[string]decimal.Decimal{"1Address": decimal.NewFromFloat(0.5)}, + Amounts: map[string]float64{"1Address": 0.5}, MinConf: btcjson.Int(6), Comment: nil, }, @@ -1035,13 +1034,13 @@ func TestWalletSvrCmds(t *testing.T) { return btcjson.NewCmd("sendmany", "from", `{"1Address":0.5}`, 6, "comment") }, staticCmd: func() interface{} { - amounts := map[string]decimal.Decimal{"1Address": decimal.NewFromFloat(0.5)} + amounts := map[string]float64{"1Address": 0.5} return btcjson.NewSendManyCmd("from", amounts, btcjson.Int(6), btcjson.String("comment")) }, - marshalled: `{"jsonrpc":"1.0","method":"sendmany","params":["from",{"1Address":"0.5"},6,"comment"],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"sendmany","params":["from",{"1Address":0.5},6,"comment"],"id":1}`, unmarshalled: &btcjson.SendManyCmd{ FromAccount: "from", - Amounts: map[string]decimal.Decimal{"1Address": decimal.NewFromFloat(0.5)}, + Amounts: map[string]float64{"1Address": 0.5}, MinConf: btcjson.Int(6), Comment: btcjson.String("comment"), }, @@ -1049,15 +1048,15 @@ func TestWalletSvrCmds(t *testing.T) { { name: "sendtoaddress", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("sendtoaddress", "1Address", decimal.NewFromFloat(0.5)) + return btcjson.NewCmd("sendtoaddress", "1Address", 0.5) }, staticCmd: func() interface{} { - return btcjson.NewSendToAddressCmd("1Address", decimal.NewFromFloat(0.5), nil, nil) + return btcjson.NewSendToAddressCmd("1Address", 0.5, nil, nil) }, - marshalled: `{"jsonrpc":"1.0","method":"sendtoaddress","params":["1Address","0.5"],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"sendtoaddress","params":["1Address",0.5],"id":1}`, unmarshalled: &btcjson.SendToAddressCmd{ Address: "1Address", - Amount: decimal.NewFromFloat(0.5), + Amount: 0.5, Comment: nil, CommentTo: nil, }, @@ -1065,16 +1064,16 @@ func TestWalletSvrCmds(t *testing.T) { { name: "sendtoaddress optional1", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("sendtoaddress", "1Address", decimal.NewFromFloat(0.5), "comment", "commentto") + return btcjson.NewCmd("sendtoaddress", "1Address", 0.5, "comment", "commentto") }, staticCmd: func() interface{} { - return btcjson.NewSendToAddressCmd("1Address", decimal.NewFromFloat(0.5), btcjson.String("comment"), + return btcjson.NewSendToAddressCmd("1Address", 0.5, btcjson.String("comment"), btcjson.String("commentto")) }, - marshalled: `{"jsonrpc":"1.0","method":"sendtoaddress","params":["1Address","0.5","comment","commentto"],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"sendtoaddress","params":["1Address",0.5,"comment","commentto"],"id":1}`, unmarshalled: &btcjson.SendToAddressCmd{ Address: "1Address", - Amount: decimal.NewFromFloat(0.5), + Amount: 0.5, Comment: btcjson.String("comment"), CommentTo: btcjson.String("commentto"), }, @@ -1096,14 +1095,14 @@ func TestWalletSvrCmds(t *testing.T) { { name: "settxfee", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("settxfee", decimal.NewFromFloat(0.0001)) + return btcjson.NewCmd("settxfee", 0.0001) }, staticCmd: func() interface{} { - return btcjson.NewSetTxFeeCmd(decimal.NewFromFloat(0.0001)) + return btcjson.NewSetTxFeeCmd(0.0001) }, - marshalled: `{"jsonrpc":"1.0","method":"settxfee","params":["0.0001"],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"settxfee","params":[0.0001],"id":1}`, unmarshalled: &btcjson.SetTxFeeCmd{ - Amount: decimal.NewFromFloat(0.0001), + Amount: 0.0001, }, }, { diff --git a/btcjson/walletsvrresults.go b/btcjson/walletsvrresults.go index 6ad8ede9..4ad74b1e 100644 --- a/btcjson/walletsvrresults.go +++ b/btcjson/walletsvrresults.go @@ -4,28 +4,24 @@ package btcjson -import "github.com/monasuite/monautil" - // GetTransactionDetailsResult models the details data from the gettransaction command. // // This models the "short" version of the ListTransactionsResult type, which // excludes fields common to the transaction. These common fields are instead // part of the GetTransactionResult. type GetTransactionDetailsResult struct { - Account string `json:"account"` - Address string `json:"address,omitempty"` - Amount float64 `json:"amount"` - AmountSatoshi monautil.Amount `json:"amount"` - Category string `json:"category"` - InvolvesWatchOnly bool `json:"involveswatchonly,omitempty"` - Fee *float64 `json:"fee,omitempty"` - Vout uint32 `json:"vout"` + Account string `json:"account"` + Address string `json:"address,omitempty"` + Amount float64 `json:"amount"` + Category string `json:"category"` + InvolvesWatchOnly bool `json:"involveswatchonly,omitempty"` + Fee *float64 `json:"fee,omitempty"` + Vout uint32 `json:"vout"` } // GetTransactionResult models the data from the gettransaction command. type GetTransactionResult struct { Amount float64 `json:"amount"` - AmountSatoshi monautil.Amount `json:"amount"` Fee float64 `json:"fee,omitempty"` Confirmations int64 `json:"confirmations"` BlockHash string `json:"blockhash"` @@ -42,72 +38,68 @@ type GetTransactionResult struct { // InfoWalletResult models the data returned by the wallet server getinfo // command. type InfoWalletResult struct { - Version int32 `json:"version"` - ProtocolVersion int32 `json:"protocolversion"` - WalletVersion int32 `json:"walletversion"` - Balance float64 `json:"balance"` - SatoshiBalance monautil.Amount `json:"balance"` - Blocks int32 `json:"blocks"` - TimeOffset int64 `json:"timeoffset"` - Connections int32 `json:"connections"` - Proxy string `json:"proxy"` - Difficulty float64 `json:"difficulty"` - TestNet bool `json:"testnet"` - KeypoolOldest int64 `json:"keypoololdest"` - KeypoolSize int32 `json:"keypoolsize"` - UnlockedUntil int64 `json:"unlocked_until"` - PaytxFee float64 `json:"paytxfee"` - RelayFee float64 `json:"relayfee"` - Errors string `json:"errors"` + Version int32 `json:"version"` + ProtocolVersion int32 `json:"protocolversion"` + WalletVersion int32 `json:"walletversion"` + Balance float64 `json:"balance"` + Blocks int32 `json:"blocks"` + TimeOffset int64 `json:"timeoffset"` + Connections int32 `json:"connections"` + Proxy string `json:"proxy"` + Difficulty float64 `json:"difficulty"` + TestNet bool `json:"testnet"` + KeypoolOldest int64 `json:"keypoololdest"` + KeypoolSize int32 `json:"keypoolsize"` + UnlockedUntil int64 `json:"unlocked_until"` + PaytxFee float64 `json:"paytxfee"` + RelayFee float64 `json:"relayfee"` + Errors string `json:"errors"` } // ListTransactionsResult models the data from the listtransactions command. type ListTransactionsResult struct { - Abandoned bool `json:"abandoned"` - Account string `json:"account"` - Address string `json:"address,omitempty"` - Amount float64 `json:"amount"` - AmountSatoshi monautil.Amount `json:"amount"` - BIP125Replaceable string `json:"bip125-replaceable,omitempty"` - BlockHash string `json:"blockhash,omitempty"` - BlockHeight *int32 `json:"blockheight,omitempty"` - BlockIndex *int64 `json:"blockindex,omitempty"` - BlockTime int64 `json:"blocktime,omitempty"` - Category string `json:"category"` - Confirmations int64 `json:"confirmations"` - Fee *float64 `json:"fee,omitempty"` - Generated bool `json:"generated,omitempty"` - InvolvesWatchOnly bool `json:"involveswatchonly,omitempty"` - Label *string `json:"label,omitempty"` - Time int64 `json:"time"` - TimeReceived int64 `json:"timereceived"` - Trusted bool `json:"trusted"` - TxID string `json:"txid"` - Vout uint32 `json:"vout"` - WalletConflicts []string `json:"walletconflicts"` - Comment string `json:"comment,omitempty"` - OtherAccount string `json:"otheraccount,omitempty"` + Abandoned bool `json:"abandoned"` + Account string `json:"account"` + Address string `json:"address,omitempty"` + Amount float64 `json:"amount"` + BIP125Replaceable string `json:"bip125-replaceable,omitempty"` + BlockHash string `json:"blockhash,omitempty"` + BlockHeight *int32 `json:"blockheight,omitempty"` + BlockIndex *int64 `json:"blockindex,omitempty"` + BlockTime int64 `json:"blocktime,omitempty"` + Category string `json:"category"` + Confirmations int64 `json:"confirmations"` + Fee *float64 `json:"fee,omitempty"` + Generated bool `json:"generated,omitempty"` + InvolvesWatchOnly bool `json:"involveswatchonly,omitempty"` + Label *string `json:"label,omitempty"` + Time int64 `json:"time"` + TimeReceived int64 `json:"timereceived"` + Trusted bool `json:"trusted"` + TxID string `json:"txid"` + Vout uint32 `json:"vout"` + WalletConflicts []string `json:"walletconflicts"` + Comment string `json:"comment,omitempty"` + OtherAccount string `json:"otheraccount,omitempty"` } // ListReceivedByAccountResult models the data from the listreceivedbyaccount // command. type ListReceivedByAccountResult struct { - Account string `json:"account"` - Amount float64 `json:"amount"` - AmountSatoshi monautil.Amount `json:"amount"` - Confirmations uint64 `json:"confirmations"` + Account string `json:"account"` + Amount float64 `json:"amount"` + Confirmations uint64 `json:"confirmations"` } // ListReceivedByAddressResult models the data from the listreceivedbyaddress // command. type ListReceivedByAddressResult struct { - Account string `json:"account"` - Address string `json:"address"` - Amount float64 `json:"amount"` - AmountSatoshi monautil.Amount `json:"amount"` - Confirmations uint64 `json:"confirmations"` - TxIDs []string `json:"txids,omitempty"` - InvolvesWatchonly bool `json:"involvesWatchonly,omitempty"` + Account string `json:"account"` + Address string `json:"address"` + Amount float64 `json:"amount"` + Confirmations uint64 `json:"confirmations"` + TxIDs []string `json:"txids,omitempty"` + InvolvesWatchonly bool `json:"involvesWatchonly,omitempty"` } // ListSinceBlockResult models the data from the listsinceblock command. @@ -118,16 +110,15 @@ type ListSinceBlockResult struct { // ListUnspentResult models a successful response from the listunspent request. type ListUnspentResult struct { - TxID string `json:"txid"` - Vout uint32 `json:"vout"` - Address string `json:"address"` - Account string `json:"account"` - ScriptPubKey string `json:"scriptPubKey"` - RedeemScript string `json:"redeemScript,omitempty"` - Amount float64 `json:"amount"` - AmountSatoshi monautil.Amount `json:"amount"` - Confirmations int64 `json:"confirmations"` - Spendable bool `json:"spendable"` + TxID string `json:"txid"` + Vout uint32 `json:"vout"` + Address string `json:"address"` + Account string `json:"account"` + ScriptPubKey string `json:"scriptPubKey"` + RedeemScript string `json:"redeemScript,omitempty"` + Amount float64 `json:"amount"` + Confirmations int64 `json:"confirmations"` + Spendable bool `json:"spendable"` } // SignRawTransactionError models the data that contains script verification @@ -173,14 +164,10 @@ type GetBestBlockResult struct { // BalanceDetailsResult models the details data from the `getbalances` command. type BalanceDetailsResult struct { - Trusted float64 `json:"trusted"` - UntrustedPending float64 `json:"untrusted_pending"` - Immature float64 `json:"immature"` - Used *float64 `json:"used"` - SatsohiTrusted monautil.Amount `json:"trusted"` - SatoshiUntrustedPending monautil.Amount `json:"untrusted_pending"` - SatoshiImmature monautil.Amount `json:"immature"` - SatoshiUsed *monautil.Amount `json:"used"` + Trusted float64 `json:"trusted"` + UntrustedPending float64 `json:"untrusted_pending"` + Immature float64 `json:"immature"` + Used *float64 `json:"used"` } // GetBalancesResult models the data returned from the getbalances command. diff --git a/btcjson/walletsvrwsntfns_test.go b/btcjson/walletsvrwsntfns_test.go index fcfe5cbb..8840d3ed 100644 --- a/btcjson/walletsvrwsntfns_test.go +++ b/btcjson/walletsvrwsntfns_test.go @@ -104,7 +104,6 @@ func TestWalletSvrWsNtfns(t *testing.T) { BIP125Replaceable: "unknown", Category: "send", Amount: 1.5, - AmountSatoshi: 150000000, Fee: btcjson.Float64(0.0001), Confirmations: 1, TxID: "456", diff --git a/docs/README.md b/docs/README.md deleted file mode 120000 index dd0ea36c..00000000 --- a/docs/README.md +++ /dev/null @@ -1 +0,0 @@ -index.md \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..82004641 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,296 @@ +### Table of Contents +1. [About](#About) +2. [Getting Started](#GettingStarted) + 1. [Installation](#Installation) + 1. [Windows](#WindowsInstallation) + 2. [Linux/BSD/MacOSX/POSIX](#PosixInstallation) + 1. [Gentoo Linux](#GentooInstallation) + 2. [Configuration](#Configuration) + 3. [Controlling and Querying monad via btcctl](#BtcctlConfig) + 4. [Mining](#Mining) +3. [Help](#Help) + 1. [Startup](#Startup) + 1. [Using bootstrap.dat](#BootstrapDat) + 2. [Network Configuration](#NetworkConfig) + 3. [Wallet](#Wallet) +4. [Contact](#Contact) + 1. [IRC](#ContactIRC) + 2. [Mailing Lists](#MailingLists) +5. [Developer Resources](#DeveloperResources) + 1. [Code Contribution Guidelines](#ContributionGuidelines) + 2. [JSON-RPC Reference](#JSONRPCReference) + 3. [The btcsuite Bitcoin-related Go Packages](#GoPackages) + + + +### 1. About + +monad is a full node bitcoin implementation written in [Go](http://golang.org), +licensed under the [copyfree](http://www.copyfree.org) ISC License. + +This project is currently under active development and is in a Beta state. It +is extremely stable and has been in production use since October 2013. + +It properly downloads, validates, and serves the block chain using the exact +rules (including consensus bugs) for block acceptance as Bitcoin Core. We have +taken great care to avoid monad causing a fork to the block chain. It includes a +full block validation testing framework which contains all of the 'official' +block acceptance tests (and some additional ones) that is run on every pull +request to help ensure it properly follows consensus. Also, it passes all of +the JSON test data in the Bitcoin Core code. + +It also properly relays newly mined blocks, maintains a transaction pool, and +relays individual transactions that have not yet made it into a block. It +ensures all individual transactions admitted to the pool follow the rules +required by the block chain and also includes more strict checks which filter +transactions based on miner requirements ("standard" transactions). + +One key difference between monad and Bitcoin Core is that monad does *NOT* include +wallet functionality and this was a very intentional design decision. See the +blog entry [here](https://web.archive.org/web/20171125143919/https://blog.conformal.com/btcd-not-your-moms-bitcoin-daemon) +for more details. This means you can't actually make or receive payments +directly with monad. That functionality is provided by the +[btcwallet](https://github.com/btcsuite/btcwallet) and +[Paymetheus](https://github.com/btcsuite/Paymetheus) (Windows-only) projects +which are both under active development. + + + +### 2. Getting Started + + + +**2.1 Installation** + +The first step is to install monad. See one of the following sections for +details on how to install on the supported operating systems. + + + +**2.1.1 Windows Installation**
+ +* Install the MSI available at: https://github.com/monasuite/monad/releases +* Launch monad from the Start Menu + +
+ +**2.1.2 Linux/BSD/MacOSX/POSIX Installation** + + +- Install Go according to the installation instructions here: + http://golang.org/doc/install + +- Ensure Go was installed properly and is a supported version: + +```bash +$ go version +$ go env GOROOT GOPATH +``` + +NOTE: The `GOROOT` and `GOPATH` above must not be the same path. It is +recommended that `GOPATH` is set to a directory in your home directory such as +`~/goprojects` to avoid write permission issues. It is also recommended to add +`$GOPATH/bin` to your `PATH` at this point. + +- Run the following commands to obtain monad, all dependencies, and install it: + +```bash +$ git clone https://github.com/monasuite/monad $GOPATH/src/github.com/monasuite/monad +$ cd $GOPATH/src/github.com/monasuite/monad +$ GO111MODULE=on go install -v . ./cmd/... +``` + +- monad (and utilities) will now be installed in ```$GOPATH/bin```. If you did + not already add the bin directory to your system path during Go installation, + we recommend you do so now. + +**Updating** + +- Run the following commands to update monad, all dependencies, and install it: + +```bash +$ cd $GOPATH/src/github.com/monasuite/monad +$ git pull && GO111MODULE=on go install -v . ./cmd/... +``` + + + +**2.1.2.1 Gentoo Linux Installation** + +* Install Layman and enable the Bitcoin overlay. + * https://gitlab.com/bitcoin/gentoo +* Copy or symlink `/var/lib/layman/bitcoin/Documentation/package.keywords/monad-live` to `/etc/portage/package.keywords/` +* Install monad: `$ emerge net-p2p/monad` + + + +**2.2 Configuration** + +monad has a number of [configuration](http://godoc.org/github.com/monasuite/monad) +options, which can be viewed by running: `$ monad --help`. + + + +**2.3 Controlling and Querying monad via btcctl** + +btcctl is a command line utility that can be used to both control and query monad +via [RPC](http://www.wikipedia.org/wiki/Remote_procedure_call). monad does +**not** enable its RPC server by default; You must configure at minimum both an +RPC username and password or both an RPC limited username and password: + +* monad.conf configuration file +``` +[Application Options] +rpcuser=myuser +rpcpass=SomeDecentp4ssw0rd +rpclimituser=mylimituser +rpclimitpass=Limitedp4ssw0rd +``` +* btcctl.conf configuration file +``` +[Application Options] +rpcuser=myuser +rpcpass=SomeDecentp4ssw0rd +``` +OR +``` +[Application Options] +rpclimituser=mylimituser +rpclimitpass=Limitedp4ssw0rd +``` +For a list of available options, run: `$ btcctl --help` + + + +**2.4 Mining** + +monad supports the `getblocktemplate` RPC. +The limited user cannot access this RPC. + + +**1. Add the payment addresses with the `miningaddr` option.** + +``` +[Application Options] +rpcuser=myuser +rpcpass=SomeDecentp4ssw0rd +miningaddr=12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX +miningaddr=1M83ju3EChKYyysmM2FXtLNftbacagd8FR +``` + +**2. Add monad's RPC TLS certificate to system Certificate Authority list.** + +`cgminer` uses [curl](http://curl.haxx.se/) to fetch data from the RPC server. +Since curl validates the certificate by default, we must install the `monad` RPC +certificate into the default system Certificate Authority list. + +**Ubuntu** + +1. Copy rpc.cert to /usr/share/ca-certificates: `# cp /home/user/.monad/rpc.cert /usr/share/ca-certificates/monad.crt` +2. Add monad.crt to /etc/ca-certificates.conf: `# echo monad.crt >> /etc/ca-certificates.conf` +3. Update the CA certificate list: `# update-ca-certificates` + +**3. Set your mining software url to use https.** + +`$ cgminer -o https://127.0.0.1:9400 -u rpcuser -p rpcpassword` + + + +### 3. Help + + + +**3.1 Startup** + +Typically monad will run and start downloading the block chain with no extra +configuration necessary, however, there is an optional method to use a +`bootstrap.dat` file that may speed up the initial block chain download process. + + + +**3.1.1 bootstrap.dat** + +* [Using bootstrap.dat](https://github.com/monasuite/monad/tree/master/docs/using_bootstrap_dat.md) + + + +**3.1.2 Network Configuration** + +* [What Ports Are Used by Default?](https://github.com/monasuite/monad/tree/master/docs/default_ports.md) +* [How To Listen on Specific Interfaces](https://github.com/monasuite/monad/tree/master/docs/configure_peer_server_listen_interfaces.md) +* [How To Configure RPC Server to Listen on Specific Interfaces](https://github.com/monasuite/monad/tree/master/docs/configure_rpc_server_listen_interfaces.md) +* [Configuring monad with Tor](https://github.com/monasuite/monad/tree/master/docs/configuring_tor.md) + + + +**3.1 Wallet** + +monad was intentionally developed without an integrated wallet for security +reasons. Please see [btcwallet](https://github.com/btcsuite/btcwallet) for more +information. + + + + +### 4. Contact + + + +**4.1 IRC** + +* [irc.freenode.net](irc://irc.freenode.net), channel `#monad` + + + +**4.2 Mailing Lists** + +* monad: discussion + of monad and its packages. +* monad-commits: + readonly mail-out of source code changes. + + + +### 5. Developer Resources + + + +* [Code Contribution Guidelines](https://github.com/monasuite/monad/tree/master/docs/code_contribution_guidelines.md) + + + +* [JSON-RPC Reference](https://github.com/monasuite/monad/tree/master/docs/json_rpc_api.md) + * [RPC Examples](https://github.com/monasuite/monad/tree/master/docs/json_rpc_api.md#ExampleCode) + + + +* The btcsuite Bitcoin-related Go Packages: + * [btcrpcclient](https://github.com/btcsuite/btcd/tree/master/rpcclient) - Implements a + robust and easy to use Websocket-enabled Bitcoin JSON-RPC client + * [btcjson](https://github.com/btcsuite/btcd/tree/master/btcjson) - Provides an extensive API + for the underlying JSON-RPC command and return values + * [wire](https://github.com/monasuite/monad/tree/master/wire) - Implements the + Bitcoin wire protocol + * [peer](https://github.com/monasuite/monad/tree/master/peer) - + Provides a common base for creating and managing Bitcoin network peers. + * [blockchain](https://github.com/monasuite/monad/tree/master/blockchain) - + Implements Bitcoin block handling and chain selection rules + * [blockchain/fullblocktests](https://github.com/monasuite/monad/tree/master/blockchain/fullblocktests) - + Provides a set of block tests for testing the consensus validation rules + * [txscript](https://github.com/monasuite/monad/tree/master/txscript) - + Implements the Bitcoin transaction scripting language + * [btcec](https://github.com/monasuite/monad/tree/master/btcec) - Implements + support for the elliptic curve cryptographic functions needed for the + Bitcoin scripts + * [database](https://github.com/monasuite/monad/tree/master/database) - + Provides a database interface for the Bitcoin block chain + * [mempool](https://github.com/monasuite/monad/tree/master/mempool) - + Package mempool provides a policy-enforced pool of unmined bitcoin + transactions. + * [monautil](https://github.com/monasuite/monautil) - Provides Bitcoin-specific + convenience functions and types + * [chainhash](https://github.com/monasuite/monad/tree/master/chaincfg/chainhash) - + Provides a generic hash type and associated functions that allows the + specific hash algorithm to be abstracted. + * [connmgr](https://github.com/monasuite/monad/tree/master/connmgr) - + Package connmgr implements a generic Bitcoin network connection manager. diff --git a/docs/configuring_tor.md b/docs/configuring_tor.md index ad2a8e79..f474372f 100644 --- a/docs/configuring_tor.md +++ b/docs/configuring_tor.md @@ -34,7 +34,11 @@ not be reachable for inbound connections unless you also configure a Tor ### Command line example ```bash -./monad --proxy=127.0.0.1:9050 +<<<<<<< HEAD +$ ./monad --proxy=127.0.0.1:9050 +======= +./btcd --proxy=127.0.0.1:9050 +>>>>>>> upstream/master ``` ### Config file example @@ -76,7 +80,11 @@ three flags: ### Command line example ```bash -./monad --proxy=127.0.0.1:9050 --listen=127.0.0.1 --externalip=fooanon.onion +<<<<<<< HEAD +$ ./monad --proxy=127.0.0.1:9050 --listen=127.0.0.1 --externalip=fooanon.onion +======= +./btcd --proxy=127.0.0.1:9050 --listen=127.0.0.1 --externalip=fooanon.onion +>>>>>>> upstream/master ``` ### Config file example @@ -111,7 +119,11 @@ routed via Tor due to the `--onion` flag. ### Command line example ```bash -./monad --onion=127.0.0.1:9050 --externalip=fooanon.onion +<<<<<<< HEAD +$ ./monad --onion=127.0.0.1:9050 --externalip=fooanon.onion +======= +./btcd --onion=127.0.0.1:9050 --externalip=fooanon.onion +>>>>>>> upstream/master ``` ### Config file example @@ -134,7 +146,11 @@ flag. This option requires --proxy or --onionproxy to be set. ### Command line example ```bash -./monad --proxy=127.0.0.1:9050 --torisolation +<<<<<<< HEAD +$ ./monad --proxy=127.0.0.1:9050 --torisolation +======= +./btcd --proxy=127.0.0.1:9050 --torisolation +>>>>>>> upstream/master ``` ### Config file example diff --git a/go.mod b/go.mod index 69948583..5e4752cb 100644 --- a/go.mod +++ b/go.mod @@ -10,9 +10,7 @@ require ( github.com/decred/dcrd/lru v1.0.0 github.com/jessevdk/go-flags v1.4.0 github.com/jrick/logrotate v1.0.0 - github.com/monasuite/monautil v1.1.2 - github.com/onsi/ginkgo v1.7.0 // indirect - github.com/onsi/gomega v1.4.3 // indirect + github.com/monasuite/monautil v1.1.1 github.com/shopspring/decimal v1.2.0 github.com/wakiyamap/lyra2rev2 v0.1.2 golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 diff --git a/go.sum b/go.sum index 66467fab..94d15b8e 100644 --- a/go.sum +++ b/go.sum @@ -10,17 +10,24 @@ github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JG github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/golangcrypto v0.0.0-20150304025918-53f62d9b43e8 h1:nOsAWScwueMVk/VLm/dvQQD7DuanyvAUb6B3P3eT274= github.com/btcsuite/golangcrypto v0.0.0-20150304025918-53f62d9b43e8/go.mod h1:tYvUd8KLhm/oXvUeSEs2VlLghFjQt9+ZaF9ghH0JNjc= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd h1:qdGvebPBDuYDPGi1WCPjy1tGyMpmDK8IEapSsszn7HE= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= github.com/btcsuite/goleveldb v1.0.0 h1:Tvd0BfvqX9o823q1j2UZ/epQo09eJh6dTcRp79ilIN4= github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723 h1:ZA/jbKoGcVAnER6pCHPEkGdZOV7U1oLUedErBHCUMs0= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/snappy-go v1.0.0 h1:ZxaA6lo2EpxGddsA8JwWOcxlzRybb444sgmeJQMJGQE= github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dchest/blake256 v1.0.0 h1:6gUgI5MHdz9g0TdrgKqXsoDX+Zjxmm1Sc6OsoGru50I= +github.com/dchest/blake256 v1.0.0/go.mod h1:xXNWCE1jsAP8DAjP+rKw2MbeqLczjI3TRx2VK+9OEYY= github.com/dchest/blake256 v1.1.0 h1:4AuEhGPT/3TTKFhTfBpZ8hgZE7wJpawcYaEawwsbtqM= github.com/dchest/blake256 v1.1.0/go.mod h1:xXNWCE1jsAP8DAjP+rKw2MbeqLczjI3TRx2VK+9OEYY= github.com/decred/dcrd/lru v1.0.0 h1:Kbsb1SFDsIlaupWPwsPp+dkxiBY1frcS07PCPgotKz8= @@ -32,23 +39,27 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89 h1:12K8AlpT0/6QUXSfV0yi4Q0jkbq8NDtIKFtF61AoqV0= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= +github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec h1:n1NeQ3SgUHyISrjFFoO5dR748Is8dBL9qpaTNfphQrs= +github.com/kkdai/bstream v0.0.0-20181106074824-b3251f7901ec/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kkdai/bstream v1.0.0 h1:Se5gHwgp2VT2uHfDrkbbgbgEvV9cimLELwrPJctSjg8= github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA= github.com/monasuite/monad v0.21.0-beta/go.mod h1:3Xp+i5gmkjEl2pUvj558OUuLsMqjB5S3663Nr0yRa58= github.com/monasuite/monad v0.22.0-beta/go.mod h1:ZHQyEBbhHEPYyhDn9VxJoWW2GJ5lZgOUtIw4xMVOAVE= -github.com/monasuite/monad v0.22.1-beta/go.mod h1:Z8IF4S54MQMjSoQ+2KAJdewQVuJsYGZ7i1fOtHgk5Zc= +github.com/monasuite/monautil v0.0.0-20190606162653-90b266792864 h1:pMKZU4hTeLssZCspx+e7yTjoluCNxcL+OPF6ipqZeHI= github.com/monasuite/monautil v0.0.0-20190606162653-90b266792864/go.mod h1:kIVSL9QpyEYOh60Z7DIAAIhzOd9pHpRbMA3rOqVXOwc= +github.com/monasuite/monautil v1.0.2 h1:lDEAgecY4QBpNP6/qZpDb6RaIsbxxCWoohg0Xc5kfUE= +github.com/monasuite/monautil v1.0.2/go.mod h1:yQwTTNPBDW7ohztctinZ+oZRTB968tVpaDFR/+8h69E= +github.com/monasuite/monautil v1.1.0 h1:LSnduPcag9hdqqOFch4oATY2SenC2OVMfMUMly/eOCU= github.com/monasuite/monautil v1.1.0/go.mod h1:b5tmGuaSp+AMFptTgNUuYWwct+WTaS+lSh2yUkQQQvw= github.com/monasuite/monautil v1.1.1 h1:My6v9Z0p+d357Q6TRM9p1k4nhQmJIs3s7yqn+lZn9Cs= github.com/monasuite/monautil v1.1.1/go.mod h1:N1fiuHcY7yZtugY+8dUeJyFjcBRJvk1z/P/KpGpkHU4= -github.com/monasuite/monautil v1.1.2 h1:TUpcVByvA6PbsFm0LcBAmfDxEsnBmQqxMaRk0syitSs= -github.com/monasuite/monautil v1.1.2/go.mod h1:KoMmpGVTPshQyrwP5L6Uno09htl1BdVjHI/OhZ+zzA8= github.com/monasuite/monautil/psbt v1.0.1/go.mod h1:7WRjsuiM52783pB5V68DM+A5EUFGQEPGZy7wd70Xay4= -github.com/monasuite/monautil/psbt v1.1.0/go.mod h1:x3L79SW2/BzpLuvRU2RNEGZmbnlQZ69exKFyld5XKtI= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -63,7 +74,10 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/wakiyamap/lyra2rev2 v0.1.2 h1:71gcx9YP9t8XJFBx/2jFbM/K0SuUbcQoX/NBSXczeFk= github.com/wakiyamap/lyra2rev2 v0.1.2/go.mod h1:G4rxLM39S2icKsHDBtzrUeEKM+7wRNEwhgpRjkYadn8= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44 h1:9lP3x0pW80sDI6t1UMSLA4to18W7R7imwAI/sWS9S8Q= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 h1:cg5LA/zNPRzIXIWSCxQW10Rvpy94aQh3LT/ShoCpkHw= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -82,12 +96,6 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20191105091915-95d230a53780/go.mod h1:3HH7i1SgMqlzxCcBmUHW657sD4Kvv9sC3HpL3YukzwA= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/rpcclient/rawtransactions.go b/rpcclient/rawtransactions.go index c44496a5..0ceb26e0 100644 --- a/rpcclient/rawtransactions.go +++ b/rpcclient/rawtransactions.go @@ -13,7 +13,6 @@ import ( "github.com/monasuite/monad/chaincfg/chainhash" "github.com/monasuite/monad/wire" "github.com/monasuite/monautil" - "github.com/shopspring/decimal" ) const ( @@ -294,9 +293,9 @@ func (r FutureCreateRawTransactionResult) Receive() (*wire.MsgTx, error) { func (c *Client) CreateRawTransactionAsync(inputs []btcjson.TransactionInput, amounts map[monautil.Address]monautil.Amount, lockTime *int64) FutureCreateRawTransactionResult { - convertedAmts := make(map[string]decimal.Decimal, len(amounts)) + convertedAmts := make(map[string]float64, len(amounts)) for addr, amount := range amounts { - convertedAmts[addr.String()] = amount.ToDecimalBTC() + convertedAmts[addr.String()] = amount.ToBTC() } cmd := btcjson.NewCreateRawTransactionCmd(inputs, convertedAmts, lockTime) return c.sendCmd(cmd) diff --git a/rpcclient/wallet.go b/rpcclient/wallet.go index 67b7ec24..fd285d33 100644 --- a/rpcclient/wallet.go +++ b/rpcclient/wallet.go @@ -475,7 +475,7 @@ func (r FutureSetTxFeeResult) Receive() error { // // See SetTxFee for the blocking version and more details. func (c *Client) SetTxFeeAsync(fee monautil.Amount) FutureSetTxFeeResult { - cmd := btcjson.NewSetTxFeeCmd(fee.ToDecimalBTC()) + cmd := btcjson.NewSetTxFeeCmd(fee.ToBTC()) return c.sendCmd(cmd) } @@ -514,7 +514,7 @@ func (r FutureSendToAddressResult) Receive() (*chainhash.Hash, error) { // See SendToAddress for the blocking version and more details. func (c *Client) SendToAddressAsync(address monautil.Address, amount monautil.Amount) FutureSendToAddressResult { addr := address.EncodeAddress() - cmd := btcjson.NewSendToAddressCmd(addr, amount.ToDecimalBTC(), nil, nil) + cmd := btcjson.NewSendToAddressCmd(addr, amount.ToBTC(), nil, nil) return c.sendCmd(cmd) } @@ -540,7 +540,7 @@ func (c *Client) SendToAddressCommentAsync(address monautil.Address, commentTo string) FutureSendToAddressResult { addr := address.EncodeAddress() - cmd := btcjson.NewSendToAddressCmd(addr, amount.ToDecimalBTC(), &comment, + cmd := btcjson.NewSendToAddressCmd(addr, amount.ToBTC(), &comment, &commentTo) return c.sendCmd(cmd) } @@ -593,7 +593,7 @@ func (r FutureSendFromResult) Receive() (*chainhash.Hash, error) { // See SendFrom for the blocking version and more details. func (c *Client) SendFromAsync(fromAccount string, toAddress monautil.Address, amount monautil.Amount) FutureSendFromResult { addr := toAddress.EncodeAddress() - cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToDecimalBTC(), nil, + cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToBTC(), nil, nil, nil) return c.sendCmd(cmd) } @@ -617,7 +617,7 @@ func (c *Client) SendFrom(fromAccount string, toAddress monautil.Address, amount // See SendFromMinConf for the blocking version and more details. func (c *Client) SendFromMinConfAsync(fromAccount string, toAddress monautil.Address, amount monautil.Amount, minConfirms int) FutureSendFromResult { addr := toAddress.EncodeAddress() - cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToDecimalBTC(), + cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToBTC(), &minConfirms, nil, nil) return c.sendCmd(cmd) } @@ -646,7 +646,7 @@ func (c *Client) SendFromCommentAsync(fromAccount string, comment, commentTo string) FutureSendFromResult { addr := toAddress.EncodeAddress() - cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToDecimalBTC(), + cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToBTC(), &minConfirms, &comment, &commentTo) return c.sendCmd(cmd) } @@ -700,9 +700,9 @@ func (r FutureSendManyResult) Receive() (*chainhash.Hash, error) { // // See SendMany for the blocking version and more details. func (c *Client) SendManyAsync(fromAccount string, amounts map[monautil.Address]monautil.Amount) FutureSendManyResult { - convertedAmounts := make(map[string]decimal.Decimal, len(amounts)) + convertedAmounts := make(map[string]float64, len(amounts)) for addr, amount := range amounts { - convertedAmounts[addr.EncodeAddress()] = amount.ToDecimalBTC() + convertedAmounts[addr.EncodeAddress()] = amount.ToBTC() } cmd := btcjson.NewSendManyCmd(fromAccount, convertedAmounts, nil, nil) return c.sendCmd(cmd) @@ -729,9 +729,9 @@ func (c *Client) SendManyMinConfAsync(fromAccount string, amounts map[monautil.Address]monautil.Amount, minConfirms int) FutureSendManyResult { - convertedAmounts := make(map[string]decimal.Decimal, len(amounts)) + convertedAmounts := make(map[string]float64, len(amounts)) for addr, amount := range amounts { - convertedAmounts[addr.EncodeAddress()] = amount.ToDecimalBTC() + convertedAmounts[addr.EncodeAddress()] = amount.ToBTC() } cmd := btcjson.NewSendManyCmd(fromAccount, convertedAmounts, &minConfirms, nil) @@ -763,9 +763,9 @@ func (c *Client) SendManyCommentAsync(fromAccount string, amounts map[monautil.Address]monautil.Amount, minConfirms int, comment string) FutureSendManyResult { - convertedAmounts := make(map[string]decimal.Decimal, len(amounts)) + convertedAmounts := make(map[string]float64, len(amounts)) for addr, amount := range amounts { - convertedAmounts[addr.EncodeAddress()] = amount.ToDecimalBTC() + convertedAmounts[addr.EncodeAddress()] = amount.ToBTC() } cmd := btcjson.NewSendManyCmd(fromAccount, convertedAmounts, &minConfirms, &comment) @@ -1244,7 +1244,7 @@ func (r FutureMoveResult) Receive() (bool, error) { // // See Move for the blocking version and more details. func (c *Client) MoveAsync(fromAccount, toAccount string, amount monautil.Amount) FutureMoveResult { - cmd := btcjson.NewMoveCmd(fromAccount, toAccount, amount.ToDecimalBTC(), nil, + cmd := btcjson.NewMoveCmd(fromAccount, toAccount, amount.ToBTC(), nil, nil) return c.sendCmd(cmd) } @@ -1265,7 +1265,7 @@ func (c *Client) Move(fromAccount, toAccount string, amount monautil.Amount) (bo func (c *Client) MoveMinConfAsync(fromAccount, toAccount string, amount monautil.Amount, minConfirms int) FutureMoveResult { - cmd := btcjson.NewMoveCmd(fromAccount, toAccount, amount.ToDecimalBTC(), + cmd := btcjson.NewMoveCmd(fromAccount, toAccount, amount.ToBTC(), &minConfirms, nil) return c.sendCmd(cmd) } @@ -1288,7 +1288,7 @@ func (c *Client) MoveMinConf(fromAccount, toAccount string, amount monautil.Amou func (c *Client) MoveCommentAsync(fromAccount, toAccount string, amount monautil.Amount, minConfirms int, comment string) FutureMoveResult { - cmd := btcjson.NewMoveCmd(fromAccount, toAccount, amount.ToDecimalBTC(), + cmd := btcjson.NewMoveCmd(fromAccount, toAccount, amount.ToBTC(), &minConfirms, &comment) return c.sendCmd(cmd) } diff --git a/rpcserver.go b/rpcserver.go index b5508b11..53c2a3b6 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -560,8 +560,7 @@ func handleCreateRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan params := s.cfg.ChainParams for encodedAddr, amount := range c.Amounts { // Ensure amount is in the valid range for monetary amounts. - if amount.Cmp(decimal.NewFromFloat(0)) != 1 || - amount.Mul(decimal.NewFromInt(monautil.SatoshiPerBitcoin)).Cmp(decimal.NewFromInt(monautil.MaxSatoshi)) == 1 { + if amount <= 0 || amount*monautil.SatoshiPerBitcoin > monautil.MaxSatoshi { return nil, &btcjson.RPCError{ Code: btcjson.ErrRPCType, Message: "Invalid amount", @@ -605,7 +604,7 @@ func handleCreateRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan } // Convert the amount to satoshi. - satoshi, err := monautil.NewAmount(amount) + satoshi, err := monautil.NewAmount(decimal.NewFromFloat(amount)) if err != nil { context := "Failed to convert amount" return nil, internalRPCError(err.Error(), context) @@ -2902,7 +2901,6 @@ func handleGetTxOut(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (i BestBlock: bestBlockHash, Confirmations: int64(confirmations), Value: monautil.Amount(value).ToBTC(), - Amount: monautil.Amount(value), ScriptPubKey: btcjson.ScriptPubKeyResult{ Asm: disbuf, Hex: hex.EncodeToString(pkScript), diff --git a/rpcserverhelp.go b/rpcserverhelp.go index e8bdbd61..022c0154 100644 --- a/rpcserverhelp.go +++ b/rpcserverhelp.go @@ -63,7 +63,6 @@ var helpDescsEnUS = map[string]string{ // PrevOut help. "prevout-addresses": "previous output addresses", "prevout-value": "previous output value", - "prevout-amount": "previous output value in satoshi", // VinPrevOut help. "vinprevout-coinbase": "The hex-encoded bytes of the signature script (coinbase txns only)", @@ -93,7 +92,6 @@ var helpDescsEnUS = map[string]string{ "vout-value": "The amount in BTC", "vout-n": "The index of this transaction output", "vout-scriptPubKey": "The public key script used to pay coins as a JSON object", - "vout-amount": "The amount in satoshi", // TxRawDecodeResult help. "txrawdecoderesult-txid": "The hash of the transaction", @@ -538,7 +536,6 @@ var helpDescsEnUS = map[string]string{ "gettxoutresult-bestblock": "The block hash that contains the transaction output", "gettxoutresult-confirmations": "The number of confirmations", "gettxoutresult-value": "The transaction amount in BTC", - "gettxoutresult-amount": "The transaction amount in satoshi", "gettxoutresult-scriptPubKey": "The public key script used to pay coins as a JSON object", "gettxoutresult-version": "The transaction version", "gettxoutresult-coinbase": "Whether or not the transaction is a coinbase", diff --git a/rpcwebsocket.go b/rpcwebsocket.go index 49aad3cd..a78ffc57 100644 --- a/rpcwebsocket.go +++ b/rpcwebsocket.go @@ -830,8 +830,7 @@ func (m *wsNotificationManager) notifyForNewTx(clients map[chan struct{}]*wsClie amount += txOut.Value } - tAmount := monautil.Amount(amount) - ntfn := btcjson.NewTxAcceptedNtfn(txHashStr, tAmount.ToDecimalBTC()) + ntfn := btcjson.NewTxAcceptedNtfn(txHashStr, monautil.Amount(amount).ToBTC()) marshalledJSON, err := btcjson.MarshalCmd(nil, ntfn) if err != nil { rpcsLog.Errorf("Failed to marshal tx notification: %s", err.Error()) diff --git a/server.go b/server.go index 11c632ec..e4c0bf01 100644 --- a/server.go +++ b/server.go @@ -2120,7 +2120,6 @@ func newPeerConfig(sp *serverPeer) *peer.Config { // not signed with its key. We could verify against their key, but // since the reference client is currently unwilling to support // other implementations' alert messages, we will not relay theirs. - // monacoin is OK? //OnAlert: nil, }, NewestBlock: sp.newestBlock,