(script, hex)
| 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); |
no test coverage detected