diff --git a/btcjson/chainsvrcmds.go b/btcjson/chainsvrcmds.go index 0cfb2e17..95993dac 100644 --- a/btcjson/chainsvrcmds.go +++ b/btcjson/chainsvrcmds.go @@ -650,7 +650,7 @@ func NewGetRawMempoolCmd(verbose *bool) *GetRawMempoolCmd { // Core even though it really should be a bool. type GetRawTransactionCmd struct { Txid string - Verbose *int `jsonrpcdefault:"0"` + Verbose *bool `jsonrpcdefault:"false"` } // NewGetRawTransactionCmd returns a new instance which can be used to issue a @@ -658,7 +658,7 @@ type GetRawTransactionCmd struct { // // The parameters which are pointers indicate they are optional. Passing nil // for optional parameters will use the default value. -func NewGetRawTransactionCmd(txHash string, verbose *int) *GetRawTransactionCmd { +func NewGetRawTransactionCmd(txHash string, verbose *bool) *GetRawTransactionCmd { return &GetRawTransactionCmd{ Txid: txHash, Verbose: verbose, diff --git a/btcjson/chainsvrcmds_test.go b/btcjson/chainsvrcmds_test.go index 95320dbd..824e87d7 100644 --- a/btcjson/chainsvrcmds_test.go +++ b/btcjson/chainsvrcmds_test.go @@ -872,21 +872,21 @@ func TestChainSvrCmds(t *testing.T) { marshalled: `{"jsonrpc":"1.0","method":"getrawtransaction","params":["123"],"id":1}`, unmarshalled: &btcjson.GetRawTransactionCmd{ Txid: "123", - Verbose: btcjson.Int(0), + Verbose: btcjson.Bool(false), }, }, { name: "getrawtransaction optional", newCmd: func() (interface{}, error) { - return btcjson.NewCmd("getrawtransaction", "123", 1) + return btcjson.NewCmd("getrawtransaction", "123", true) }, staticCmd: func() interface{} { - return btcjson.NewGetRawTransactionCmd("123", btcjson.Int(1)) + return btcjson.NewGetRawTransactionCmd("123", btcjson.Bool(true)) }, - marshalled: `{"jsonrpc":"1.0","method":"getrawtransaction","params":["123",1],"id":1}`, + marshalled: `{"jsonrpc":"1.0","method":"getrawtransaction","params":["123",true],"id":1}`, unmarshalled: &btcjson.GetRawTransactionCmd{ Txid: "123", - Verbose: btcjson.Int(1), + Verbose: btcjson.Bool(true), }, }, { diff --git a/docs/json_rpc_api.md b/docs/json_rpc_api.md index 17ccba64..195b227c 100644 --- a/docs/json_rpc_api.md +++ b/docs/json_rpc_api.md @@ -436,7 +436,7 @@ the method name for further details such as parameter and return information. | | | | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Method | getrawtransaction | -| Parameters | 1. transaction hash (string, required) - the hash of the transaction
2. verbose (int, optional, default=0) - specifies the transaction is returned as a JSON object instead of hex-encoded string | +| Parameters | 1. transaction hash (string, required) - the hash of the transaction
2. verbose (bool, optional, default=false) - specifies the transaction is returned as a JSON object instead of hex-encoded string | | Description | Returns information about a transaction given its hash. | | Returns (verbose=0) | `"data" (string) hex-encoded bytes of the serialized transaction` | | Returns (verbose=1) | `{ (json object)`
  `"hex": "data", (string) hex-encoded transaction`
  `"txid": "hash", (string) the hash of the transaction`
  `"version": n, (numeric) the transaction version`
  `"locktime": n, (numeric) the transaction lock time`
  `"vin": [ (array of json objects) the transaction inputs as json objects`
  For coinbase transactions:
    `{ (json object)`
      `"coinbase": "data", (string) the hex-encoded bytes of the signature script`
      `"sequence": n, (numeric) the script sequence number`
    `"txinwitness": “data", (string) the witness stack for the input`
    `}`
  For non-coinbase transactions:
    `{ (json object)`
      `"txid": "hash", (string) the hash of the origin transaction`
      `"vout": n, (numeric) the index of the output being redeemed from the origin transaction`
      `"scriptSig": { (json object) the signature script used to redeem the origin transaction`
        `"asm": "asm", (string) disassembly of the script`
        `"hex": "data", (string) hex-encoded bytes of the script`
      `}`
      `"sequence": n, (numeric) the script sequence number`
    `"txinwitness": “data", (string) the witness stack for the input`
    `}, ...`
  `]`
  `"vout": [ (array of json objects) the transaction outputs as json objects`
    `{ (json object)`
      `"value": n, (numeric) the value in BTC`
      `"n": n, (numeric) the index of this transaction output`
      `"scriptPubKey": { (json object) the public key script used to pay coins`
        `"asm": "asm", (string) disassembly of the script`
        `"hex": "data", (string) hex-encoded bytes of the script`
        `"reqSigs": n, (numeric) the number of required signatures`
        `"type": "scripttype" (string) the type of the script (e.g. 'pubkeyhash')`
        `"addresses": [ (json array of string) the bitcoin addresses associated with this output`
          `"bitcoinaddress", (string) the bitcoin address`
          `...`
        `]`
      `}`
    `}, ...`
  `]`
`}` | diff --git a/rpcclient/rawtransactions.go b/rpcclient/rawtransactions.go index 3512ccb7..e4402f1d 100644 --- a/rpcclient/rawtransactions.go +++ b/rpcclient/rawtransactions.go @@ -108,7 +108,7 @@ func (c *Client) GetRawTransactionAsync(txHash *chainhash.Hash) FutureGetRawTran hash = txHash.String() } - cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Int(0)) + cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Bool(false)) return c.SendCmd(cmd) } @@ -154,7 +154,7 @@ func (c *Client) GetRawTransactionVerboseAsync(txHash *chainhash.Hash) FutureGet hash = txHash.String() } - cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Int(1)) + cmd := btcjson.NewGetRawTransactionCmd(hash, btcjson.Bool(true)) return c.SendCmd(cmd) } diff --git a/rpcserver.go b/rpcserver.go index 91ddf64e..9dd42a70 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2782,7 +2782,7 @@ func handleGetRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan str verbose := false if c.Verbose != nil { - verbose = *c.Verbose != 0 + verbose = *c.Verbose } // Try to fetch the transaction from the memory pool and if that fails,