public void TestToString() { Address one = new Address("XMHLMNAVJIMAW2RHJXLXKKK4G3J3U6VONNO3BTAQYVDC3MHTGDP3J5OCRU"); Address two = new Address("HTNOX33OCQI2JCOLZ2IRM3BC2WZ6JUILSLEORBPFI6W7GU5Q4ZW6LINHLA"); Address three = new Address("E6JSNTY4PVCY3IRZ6XEDHEO6VIHCQ5KGXCIQKFQCMB2N6HXRY4IB43VSHI"); MultisigAddress addr = new MultisigAddress(1, 2, new List <Ed25519PublicKeyParameters> { new Ed25519PublicKeyParameters(one.Bytes, 0), new Ed25519PublicKeyParameters(two.Bytes, 0), new Ed25519PublicKeyParameters(three.Bytes, 0), }); Assert.AreEqual(addr.ToAddress().ToString(), "UCE2U2JC4O4ZR6W763GUQCG57HQCDZEUJY4J5I6VYY4HQZUJDF7AKZO5GM"); TestUtil.SerializeDeserializeCheck(addr); }
public void testSignMultisigTransaction() { MultisigAddress addr = makeTestMsigAddr(); // build unsigned transaction var tx = new Transaction(addr.ToAddress(), 217000, 972508, 973508, Convert.FromBase64String("tFF5Ofz60nE="), 5000, new Address("DN7MBMCL5JQ3PFUQS7TMX5AH4EEKOBJVDUF4TCV6WERATKFLQF4MQUPZTA"), "testnet-v31.0", new Digest()); byte[] seed = Mnemonic.ToKey("auction inquiry lava second expand liberty glass involve ginger illness length room item discover ahead table doctor term tackle cement bonus profit right above catch"); Account account = new Account(seed); SignedTransaction stx = account.SignMultisigTransaction(addr, tx); byte[] enc = Encoder.EncodeToMsgPack(stx); // check main signature is correct byte[] golden = Convert.FromBase64String("gqRtc2lng6ZzdWJzaWeTgqJwa8QgG37AsEvqYbeWkJfmy/QH4QinBTUdC8mKvrEiCairgXihc8RAdvZ3y9GsInBPutdwKc7Jy+an13CcjSV1lcvRAYQKYOxXwfgT5B/mK14R57ueYJTYyoDO8zBY6kQmBalWkm95AIGicGvEIAljMglTc4nwdWcRdzmRx9A+G3PIxPUr9q/wGqJc+cJxgaJwa8Qg5/D4TQaBHfnzHI2HixFV9GcdUaGFwgCQhmf0SVhwaKGjdGhyAqF2AaN0eG6Jo2FtdM0TiKNmZWXOAANPqKJmds4ADtbco2dlbq10ZXN0bmV0LXYzMS4womx2zgAO2sSkbm90ZcQItFF5Ofz60nGjcmN2xCAbfsCwS+pht5aQl+bL9AfhCKcFNR0LyYq+sSIJqKuBeKNzbmTEII2StImQAXOgTfpDWaNmamr86ixCoF3Zwfc+66VHgDfppHR5cGWjcGF5"); Assert.AreEqual(enc, golden); }
public void testLogicsigMultisigSignature() { byte[] program = { 0x01, 0x20, 0x01, 0x01, 0x22 /*int 1*/ }; Address one = new Address("DN7MBMCL5JQ3PFUQS7TMX5AH4EEKOBJVDUF4TCV6WERATKFLQF4MQUPZTA"); Address two = new Address("BFRTECKTOOE7A5LHCF3TTEOH2A7BW46IYT2SX5VP6ANKEXHZYJY77SJTVM"); Address three = new Address("47YPQTIGQEO7T4Y4RWDYWEKV6RTR2UNBQXBABEEGM72ESWDQNCQ52OPASU"); MultisigAddress ma = new MultisigAddress(1, 2, new List <Ed25519PublicKeyParameters> { new Ed25519PublicKeyParameters(one.Bytes, 0), new Ed25519PublicKeyParameters(two.Bytes, 0), new Ed25519PublicKeyParameters(three.Bytes, 0), }); string mn1 = "auction inquiry lava second expand liberty glass involve ginger illness length room item discover ahead table doctor term tackle cement bonus profit right above catch"; string mn2 = "since during average anxiety protect cherry club long lawsuit loan expand embark forum theory winter park twenty ball kangaroo cram burst board host ability left"; Account acc1 = new Account(mn1); Account acc2 = new Account(mn2); Account account = new Account(); LogicsigSignature lsig = new LogicsigSignature(program); lsig = acc1.SignLogicsig(lsig, ma); Assert.AreEqual(lsig.logic, program); Assert.IsNull(lsig.args); Assert.IsNull(lsig.sig); Assert.AreNotEqual(lsig.msig, new MultisigSignature()); Assert.IsNotNull(lsig.msig); var verified = lsig.Verify(ma.ToAddress()); Assert.IsFalse(verified); LogicsigSignature lsigLambda = lsig; //Assert.AreEqualThrownBy(()->account.appendToLogicsig(lsigLambda)) // .isInstanceOf(IllegalArgumentException.class) // .hasMessage("Multisig account does not contain this secret key"); lsig = acc2.AppendToLogicsig(lsig); verified = lsig.Verify(ma.ToAddress()); Assert.IsTrue(verified); // Add a single signature and ensure it fails LogicsigSignature lsig1 = new LogicsigSignature(program); lsig1 = account.SignLogicsig(lsig1); lsig.sig = lsig1.sig; verified = lsig.Verify(ma.ToAddress()); Assert.IsFalse(verified); verified = lsig.Verify(account.Address); Assert.IsFalse(verified); // Remove and ensure it still works lsig.sig = null; verified = lsig.Verify(ma.ToAddress()); Assert.IsTrue(verified); // check serialization byte[] outBytes = Encoder.EncodeToMsgPack(lsig); LogicsigSignature lsig2 = Encoder.DecodeFromMsgPack <LogicsigSignature>(outBytes); Assert.AreEqual(lsig2, lsig); verified = lsig2.Verify(ma.ToAddress()); Assert.IsTrue(verified); TestUtil.SerializeDeserializeCheck(lsig2); }