* Get the script to the equivalent witness * program (mimics bitcoind's scriptForWitness). * @returns {Script|null}
()
| 2122 | */ |
| 2123 | |
| 2124 | forWitness() { |
| 2125 | if (this.isProgram()) |
| 2126 | return this.clone(); |
| 2127 | |
| 2128 | const pk = this.getPubkey(); |
| 2129 | if (pk) { |
| 2130 | const hash = hash160.digest(pk); |
| 2131 | return Script.fromProgram(0, hash); |
| 2132 | } |
| 2133 | |
| 2134 | const pkh = this.getPubkeyhash(); |
| 2135 | if (pkh) |
| 2136 | return Script.fromProgram(0, pkh); |
| 2137 | |
| 2138 | return Script.fromProgram(0, this.sha256()); |
| 2139 | } |
| 2140 | |
| 2141 | /** |
| 2142 | * Test whether the output script is |
no test coverage detected