Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tom
crown-core
Commits
3aa3ebf8
Commit
3aa3ebf8
authored
11 years ago
by
Peter Todd
Browse files
Options
Download
Email Patches
Plain Diff
Add RPC call decodescript
parent
14c3aa6a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/bitcoinrpc.cpp
+1
-0
src/bitcoinrpc.cpp
src/bitcoinrpc.h
+1
-0
src/bitcoinrpc.h
src/rpcblockchain.cpp
+2
-2
src/rpcblockchain.cpp
src/rpcrawtransaction.cpp
+27
-3
src/rpcrawtransaction.cpp
with
31 additions
and
5 deletions
+31
-5
src/bitcoinrpc.cpp
View file @
3aa3ebf8
...
...
@@ -280,6 +280,7 @@ static const CRPCCommand vRPCCommands[] =
{
"getrawtransaction"
,
&
getrawtransaction
,
false
,
false
},
{
"createrawtransaction"
,
&
createrawtransaction
,
false
,
false
},
{
"decoderawtransaction"
,
&
decoderawtransaction
,
false
,
false
},
{
"decodescript"
,
&
decodescript
,
false
,
false
},
{
"signrawtransaction"
,
&
signrawtransaction
,
false
,
false
},
{
"sendrawtransaction"
,
&
sendrawtransaction
,
false
,
false
},
{
"gettxoutsetinfo"
,
&
gettxoutsetinfo
,
true
,
false
},
...
...
This diff is collapsed.
Click to expand it.
src/bitcoinrpc.h
View file @
3aa3ebf8
...
...
@@ -207,6 +207,7 @@ extern json_spirit::Value lockunspent(const json_spirit::Array& params, bool fHe
extern
json_spirit
::
Value
listlockunspent
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
createrawtransaction
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
decoderawtransaction
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
decodescript
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
signrawtransaction
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
sendrawtransaction
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
...
...
This diff is collapsed.
Click to expand it.
src/rpcblockchain.cpp
View file @
3aa3ebf8
...
...
@@ -9,7 +9,7 @@
using
namespace
json_spirit
;
using
namespace
std
;
void
ScriptPubKeyToJSON
(
const
CScript
&
scriptPubKey
,
Object
&
out
);
void
ScriptPubKeyToJSON
(
const
CScript
&
scriptPubKey
,
Object
&
out
,
bool
fIncludeHex
);
double
GetDifficulty
(
const
CBlockIndex
*
blockindex
)
{
...
...
@@ -245,7 +245,7 @@ Value gettxout(const Array& params, bool fHelp)
ret
.
push_back
(
Pair
(
"confirmations"
,
pcoinsTip
->
GetBestBlock
()
->
nHeight
-
coins
.
nHeight
+
1
));
ret
.
push_back
(
Pair
(
"value"
,
ValueFromAmount
(
coins
.
vout
[
n
].
nValue
)));
Object
o
;
ScriptPubKeyToJSON
(
coins
.
vout
[
n
].
scriptPubKey
,
o
);
ScriptPubKeyToJSON
(
coins
.
vout
[
n
].
scriptPubKey
,
o
,
true
);
ret
.
push_back
(
Pair
(
"scriptPubKey"
,
o
));
ret
.
push_back
(
Pair
(
"version"
,
coins
.
nVersion
));
ret
.
push_back
(
Pair
(
"coinbase"
,
coins
.
fCoinBase
));
...
...
This diff is collapsed.
Click to expand it.
src/rpcrawtransaction.cpp
View file @
3aa3ebf8
...
...
@@ -17,14 +17,15 @@ using namespace boost;
using
namespace
boost
::
assign
;
using
namespace
json_spirit
;
void
ScriptPubKeyToJSON
(
const
CScript
&
scriptPubKey
,
Object
&
out
)
void
ScriptPubKeyToJSON
(
const
CScript
&
scriptPubKey
,
Object
&
out
,
bool
fIncludeHex
)
{
txnouttype
type
;
vector
<
CTxDestination
>
addresses
;
int
nRequired
;
out
.
push_back
(
Pair
(
"asm"
,
scriptPubKey
.
ToString
()));
out
.
push_back
(
Pair
(
"hex"
,
HexStr
(
scriptPubKey
.
begin
(),
scriptPubKey
.
end
())));
if
(
fIncludeHex
)
out
.
push_back
(
Pair
(
"hex"
,
HexStr
(
scriptPubKey
.
begin
(),
scriptPubKey
.
end
())));
if
(
!
ExtractDestinations
(
scriptPubKey
,
type
,
addresses
,
nRequired
))
{
...
...
@@ -73,7 +74,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
out
.
push_back
(
Pair
(
"value"
,
ValueFromAmount
(
txout
.
nValue
)));
out
.
push_back
(
Pair
(
"n"
,
(
boost
::
int64_t
)
i
));
Object
o
;
ScriptPubKeyToJSON
(
txout
.
scriptPubKey
,
o
);
ScriptPubKeyToJSON
(
txout
.
scriptPubKey
,
o
,
false
);
out
.
push_back
(
Pair
(
"scriptPubKey"
,
o
));
vout
.
push_back
(
out
);
}
...
...
@@ -301,6 +302,29 @@ Value decoderawtransaction(const Array& params, bool fHelp)
return
result
;
}
Value
decodescript
(
const
Array
&
params
,
bool
fHelp
)
{
if
(
fHelp
||
params
.
size
()
!=
1
)
throw
runtime_error
(
"decodescript <hex string>
\n
"
"Decode a hex-encoded script."
);
RPCTypeCheck
(
params
,
list_of
(
str_type
));
Object
r
;
CScript
script
;
if
(
params
[
0
].
get_str
().
size
()
>
0
){
vector
<
unsigned
char
>
scriptData
(
ParseHexV
(
params
[
0
],
"argument"
));
script
=
CScript
(
scriptData
.
begin
(),
scriptData
.
end
());
}
else
{
// Empty scripts are valid
}
ScriptPubKeyToJSON
(
script
,
r
,
false
);
r
.
push_back
(
Pair
(
"p2sh"
,
CBitcoinAddress
(
script
.
GetID
()).
ToString
()));
return
r
;
}
Value
signrawtransaction
(
const
Array
&
params
,
bool
fHelp
)
{
if
(
fHelp
||
params
.
size
()
<
1
||
params
.
size
()
>
4
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help