[lbry] rpc: update getrawtransaction to take verbose as boolean
This commit is contained in:
parent
239d681f28
commit
a7f971f404
5 changed files with 11 additions and 11 deletions
|
@ -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,
|
||||
|
|
|
@ -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),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -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<br />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<br />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)`<br /> `"hex": "data", (string) hex-encoded transaction`<br /> `"txid": "hash", (string) the hash of the transaction`<br /> `"version": n, (numeric) the transaction version`<br /> `"locktime": n, (numeric) the transaction lock time`<br /> `"vin": [ (array of json objects) the transaction inputs as json objects`<br /> <font color="orange">For coinbase transactions:</font><br /> `{ (json object)`<br /> `"coinbase": "data", (string) the hex-encoded bytes of the signature script`<br /> `"sequence": n, (numeric) the script sequence number`<br /> `"txinwitness": “data", (string) the witness stack for the input`<br /> `}`<br /> <font color="orange">For non-coinbase transactions:</font><br /> `{ (json object)`<br /> `"txid": "hash", (string) the hash of the origin transaction`<br /> `"vout": n, (numeric) the index of the output being redeemed from the origin transaction`<br /> `"scriptSig": { (json object) the signature script used to redeem the origin transaction`<br /> `"asm": "asm", (string) disassembly of the script`<br /> `"hex": "data", (string) hex-encoded bytes of the script`<br /> `}`<br /> `"sequence": n, (numeric) the script sequence number`<br /> `"txinwitness": “data", (string) the witness stack for the input`<br /> `}, ...`<br /> `]`<br /> `"vout": [ (array of json objects) the transaction outputs as json objects`<br /> `{ (json object)`<br /> `"value": n, (numeric) the value in BTC`<br /> `"n": n, (numeric) the index of this transaction output`<br /> `"scriptPubKey": { (json object) the public key script used to pay coins`<br /> `"asm": "asm", (string) disassembly of the script`<br /> `"hex": "data", (string) hex-encoded bytes of the script`<br /> `"reqSigs": n, (numeric) the number of required signatures`<br /> `"type": "scripttype" (string) the type of the script (e.g. 'pubkeyhash')`<br /> `"addresses": [ (json array of string) the bitcoin addresses associated with this output`<br /> `"bitcoinaddress", (string) the bitcoin address`<br /> `...`<br /> `]`<br /> `}`<br /> `}, ...`<br /> `]`<br />`}` |
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue