public void Tx_Out_Address() { //single output tests var tests = new string[][] { //P2PK new string[] { "12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX", "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000" }, //P2PKH new string[] { "18xRrVE5SGdD3QYgszxYyEjuCeHnfqMTqH", "0100000002144e211274abfee1ea9d63bb40002f36d6a0955d051649d460ac43c2631b6cae010000006b483045022100f0762d76613f2775445d6bd0e944c93e213d8b61aa314f56641c6692dc620a0f022077b6cec522f57ce3e21be954c3b0d24883fd946623a0fecfa44eceb5a6f14e9301210328582a9204abf0ee920f54c64adf5359b720fc44019b518ed214c997c531aac1ffffffff3dc9ace14aaf623bab12ea6ff7e8010954282654ab9042b18b913b621328726f000000006a473044022041d81ae917b556ab903e6a2d65af896de49e5ebc48ea4aba5a60dfae6b077d8d02202bddb8b3be71753c4fa9c22d418982566a80a657d8fccf46ab78b293bd615f8f012103184f0018baae12bf2499c4a868bfb9f05d94093596cfcc1dd505b366038da642ffffffff01f6537b0b000000001976a9145744813aff6759cc19595547e9947c21fc7c07f088ac00000000" }, //P2SH new string[] { "3AZdx7cGMU1prFer7gzsmeNzERzo7pPSAP", "010000000162220eace15cc50893da8ec40a0aa8a4f890b60405f0d8ffcce3ceae1f65eda2030000006a4730440220516b1584bc1fcae77a6a04aada82b5663864e0f734a75d2a5bd643dbb271703802205cf4e92e9bb47bbd78484956a96b68f15701fface600182760a382e0a1afddb801210320d6ff1346469239bf7f147fcb8154b1dd22329d6409757c290a6762f8d6162cffffffff01e4f8a8000000000017a9146153e0d56d97dbbe56a5214a1289f6221ea6249a8700000000" }, //P2SH_P2WPKH new string[] { "bc1qc8jgyt0wc4tv3nym274gn4fwe58tlswe5uhdjz", "010000000001019b5d5dfeff3f451a456b5bab1d2930f34ce940bb3bbf5c0794ddf8fd98f7c9f004000000171600147826fe22125ae742c3b91e7e6e41a7d743c25de1ffffffff02eb68000000000000160014c1e4822deec556c8cc9b57aa89d52ecd0ebfc1d99e790900000000001976a914153e989ec362cfdf14f46e8f3a986735dfc11cdd88ac02483045022100a0b07e0e0aa8a44f17b43bbd02045efa52224ac5aaac4db6ec08899dfc460c7d02200be3181a13dbc72a92777941c991cac0f01322563d34343404e4d0a2cedb9aec012103424b3498226467f8b015fe5c7d5f2e002c265242d0b3c3533f74a38b019580d200000000" }, //P2WSH new string[] { "bc1qpapzchprzhnhg5kcamfm3vmfjlx49hzqjh5s2vrp38yst6fm9rkqmnhq3a", "0200000000010130c62a0fa62608f378b13645b89ef15ffce557414a35a251727dc3cf8a12aa050100000000a70d9980010e8a0700000000002200200f422c5c2315e77452d8eed3b8b36997cd52dc4095e905306189c905e93b28ec0400483045022100ac56ad14a790e0677ebceafc64d29a95eb9d6aa503bec173cdb57087d25f690302204b2e8dfd9e89f0d7917e423f50a49c86a786275cad320514ffefc4602723d8750147304402206e6b06e66a17d40674b93e47e11100c90ed8625231c1591ba66d92a958b8b9f00220734d487437d0084cd9fb5e7d15b2e5a87ab0bd25e495711c1bb69519fac3130c0147522102e6c7484ed0dd6b3632644c20b070dd64f1034fbb601206b6eaca08da8806bb81210365213c3d159cb62fe849f5ff2760d9bdb1784fdf362cb6d0eae1cdd4fe31369b52ae86125d20" } }; foreach (var t in tests) { var tx = new Tx(); #if NETCOREAPP2_1 tx.ReadFromPayload(t[1].FromHex()); #else tx.ReadFromPayload(t[1].FromHex(), 0); #endif Assert.Equal(t[0], tx.TxOut[0].GetAddress().ToString()); } }
public void Tx_Parse() { var tx = "0100000001bb32aec76593327a638825be7fa38c1e48ff1bbe19f228963eb1737b248634d1010000006a47304402206bab89949b0aee41c3e6d548cad04784f35183d0d75c026566922e9dbb7d8434022005decf93695e7e88e8002758ae7605cb5d639f4bed6985c5c3150ed6af14c0f501210334bcc78a4bbe00b52c557ab2f4e0aa53c88cb52ce25882d287f37d0b2a5886adffffffff02f4b901000000000017a914068bccbacf3b33f71693ed1d59d409dad561f537876f96d521000000001976a914ee36e696e8ef973850f198a062bb8a3aee3fde9f88ac00000000".ToUpper().FromHex(); var tx_parsed = new Tx(); #if NETCOREAPP2_1 tx_parsed.ReadFromPayload(tx); #else tx_parsed.ReadFromPayload(tx, 0); #endif Assert.True(tx_parsed.Version == 1); Assert.True(tx_parsed.TxIn.Length == 1); Assert.True(tx_parsed.TxOut.Length == 2); Assert.True(tx_parsed.TxOut[0].Value == 113140); Assert.True(tx_parsed.TxOut[1].Value == 567645807); }
public void Tx_Segwit_Parse() { var tx = "010000000001014bae8902e8dbc5260239c2af6e3b5ef066bbf1e17ecd82d9e28274573a66223a0400000000ffffffff0260e6e4650000000017a914483a524b6b66bbbb81f3954d4d622ae625a932d98750905e1100000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d0400483045022100aa7b28cf7ad4ef3ee2b09b3526dc80357686400909fe2737c7bdeb4dc5e37cc6022022c45cc7aaa782a3466d6dce70e7fb37fdd7290b716d736259bfa399c6429daf01483045022100c27699aaddc48f02c742a6ea15400fd5d4607fdf2d1f4ea3a7cfb76c2e43a14302206ad6447e4db9c89d9c24ee8a41bb103a3aee08f9a42b7849803e11cb9a8348e2016952210266edd4ef2953675faf0662c088a7f620935807d200d65387290b31648e51e253210372ce38027ee95c98cdc54172964fa3aecf9f24b85c139d3d203365d6b691d0502103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000".ToUpper().FromHex(); var tx_parsed = new Tx(); #if NETCOREAPP2_1 tx_parsed.ReadFromPayload(tx); #else tx_parsed.ReadFromPayload(tx, 0); #endif Assert.True(tx_parsed.Version == 1); Assert.True(tx_parsed.TxIn.Length == 1); Assert.True(tx_parsed.TxOut.Length == 2); Assert.True(tx_parsed.TxOut[0].Value == 1709500000); Assert.True(tx_parsed.TxOut[1].Value == 291410000); }
public void Script_Witness_Verify() { var prev_tx = "01000000000101143663e4d2cdb0c4c4be480c1ba02c9983a9432af4549d0a79e7f600558e3ed10600000000ffffffff090084d7170000000017a914dcd19ff6b8cf942d558835f30ee49bf0c58cafbc8760892500000000001976a914d33d34d68a428c6b90a23a6eb106b8425d97942288ac0075a800000000001976a9142bf905f888c27babdf00b763a2ae59c74661633e88ac40771b00000000001976a914576cb1215cd96fd944ae2d65cfd6007918b664d588ace0673500000000001976a91422b32cd4ebf5940b0be060dec1d1948acd7a7ad488ac404b4c00000000001976a914b7c7e27153f41acd2c82f969b30b697e7877996688ac00093d000000000017a9142fe71b630bd770a12f7730a9d802751d523d038487a0072b00000000001976a91454a502e84da171584e31dfae7103039106f7017388ac0034891000000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d040047304402201f589ebdee367c09bc8130170a4d8628fc92acae0113f1f078ed0acaa519c81a02200b8164f75949585317464cfe5ef9bb0480bd6236f39cff869d511e34a3b2eaa20147304402200af5e964046da3fc0a5064cddc95c7d044e015af131badaa27b1555776c40bcc02207b1b55731f10a084f9c39333fce454d614646efe4f635bf3b5f76e829b1bcac9016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000".FromHex(); var prev_tx_parsed = new Tx(); #if NETCOREAPP2_1 prev_tx_parsed.ReadFromPayload(prev_tx); //vout 8 in this case for the below tx #else prev_tx_parsed.ReadFromPayload(prev_tx, 0); //vout 8 in this case for the below tx #endif // 2-of-3 multisig P2WSH //txid: bb52a350bb27191522573d1d5b79cf5f503c918e05988b04085774dc816c444d var tx = "0100000000010139e82f99965dce11ee96fbe484f9f31cb7854910100734b205708809bc31a9480800000000ffffffff02c0336c04000000001976a9140185b799d6b09d74515f6b6101798000e190308888acb0a01b0c00000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d0400483045022100b054fb57517fea8a7806f60510c8d94e86e1f66e33ffb80ca5ff41e31abb72a202207d72428da2aef2f04a9b0af1e5bae8245595441de0995dbb3caa082c29a2c2ca0147304402203b873c6b048295a114e90d31a9f4a78a6e03a9caf94f14d05542b8d17975671c02200532f3b4653bcf72f2c3c39629c87af131949fbdcad5add868a9628990734084016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000".FromHex(); var tx_parsed = new Tx(); #if NETCOREAPP2_1 tx_parsed.ReadFromPayload(tx.AsSpan()); #else tx_parsed.ReadFromPayload(tx, 0); #endif }