Created
September 12, 2023 14:11
-
-
Save kushti/0eecded525f0c9778fd93858291fa770 to your computer and use it in GitHub Desktop.
p2sh.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object p2shTester extends App { | |
val p2shaddr = "4MQyML64GnzMxZgm" | |
val ae = ErgoAddressEncoder.Mainnet | |
val prop = ae.fromString(p2shaddr).get.script.toProposition(true) | |
val bs = ValueSerializer.serialize(prop) | |
val bac = ByteArrayConstant(bs) | |
val r = SigmaSerializer.startReader(bs) | |
val script = ValueSerializer.deserialize(r) // Why ValueSerializer? read NOTE above | |
println(script) | |
println(ae.fromString(p2shaddr).get.script.bytes.mkString(", ")) | |
val i0 = Input(ADKey @@ Base16.decode("67245fe75ce678b8d94713fa0158189f03dabd0a4374d4bb2cbe01a595dc2737").get, | |
new ProverResult(Array.emptyByteArray, new ContextExtension(Map(Pay2SHAddress.scriptId -> bac)))) | |
val o0 = new ErgoBoxCandidate(100000000, ErgoTreePredef.feeProposition(),1089453) | |
val etr = new ErgoTransaction(IndexedSeq(i0), IndexedSeq.empty, IndexedSeq(o0)) | |
val sc = ErgoStateContext.empty(ErgoSettings.read(), LaunchParameters) | |
val boxesToSpend = IndexedSeq(ErgoBoxSerializer.parseBytes(Base16.decode("80c2d72f00ea02d193b4cbe4e3010e040004300e18d62151f990f191c102a6fe995b89ed3d0f343a96f13789a3d40801efbe420000129319c9b8849c6ba02961f7c15fe6b1d239d9c93cf9deb114ed73e1a4b6e38000").get)) | |
//println(etr.validateStateful(boxesToSpend, IndexedSeq.empty, sc, 0)(new ErgoInterpreter(LaunchParameters)).result.toTry) | |
println(etr.asJson) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment