MCPcopy Index your code
hub / github.com/bcoin-org/bcoin / scriptToJSON

Method scriptToJSON

lib/node/rpc.js:2678–2706  ·  view source on GitHub ↗
(script, hex)

Source from the content-addressed store, hash-verified

2676 }
2677
2678 scriptToJSON(script, hex) {
2679 const type = script.getType();
2680
2681 const json = {
2682 asm: script.toASM(),
2683 hex: undefined,
2684 type: Script.typesByVal[type],
2685 reqSigs: 1,
2686 addresses: [],
2687 p2sh: undefined
2688 };
2689
2690 if (hex)
2691 json.hex = script.toJSON();
2692
2693 const [m] = script.getMultisig();
2694
2695 if (m !== -1)
2696 json.reqSigs = m;
2697
2698 const addr = script.getAddress();
2699
2700 if (addr) {
2701 const str = addr.toString(this.network);
2702 json.addresses.push(str);
2703 }
2704
2705 return json;
2706 }
2707
2708 async headerToJSON(entry) {
2709 const mtp = await this.chain.getMedianTime(entry);

Callers 3

getTXOutMethod · 0.95
decodeScriptMethod · 0.95
txToJSONMethod · 0.95

Calls 7

getMultisigMethod · 0.80
getTypeMethod · 0.45
toASMMethod · 0.45
toJSONMethod · 0.45
getAddressMethod · 0.45
toStringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected