CreateSignatureRedeemScript() public static method

public static CreateSignatureRedeemScript ( ECPoint publicKey ) : byte[]
publicKey ECPoint
return byte[]
示例#1
0
        public void TestCreateAccountBySmartContract()
        {
            byte[] privateKey = new byte[32];
            using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(privateKey);
            }
            KeyPair key = new KeyPair(privateKey);
            VerificationContract contract = new VerificationContract
            {
                Script        = Contract.CreateSignatureRedeemScript(key.PublicKey),
                ParameterList = new[] { ContractParameterType.Signature }
            };
            var account   = wallet.CreateAccount(contract, key);
            var dbAccount = wallet.GetAccount(account.ScriptHash);

            account.Should().Be(dbAccount);

            byte[] privateKey2 = new byte[32];
            using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(privateKey2);
            }
            KeyPair  key2      = new KeyPair(privateKey2);
            Contract contract2 = new Contract
            {
                Script        = Contract.CreateSignatureRedeemScript(key2.PublicKey),
                ParameterList = new[] { ContractParameterType.Signature }
            };
            var account2   = wallet.CreateAccount(contract2, key2);
            var dbAccount2 = wallet.GetAccount(account2.ScriptHash);

            account2.Should().Be(dbAccount2);
        }
示例#2
0
        public void TestGetAccount()
        {
            bool result = uut.Contains(testScriptHash);

            Assert.AreEqual(false, result);
            uut.CreateAccount(keyPair.PrivateKey);
            result = uut.Contains(testScriptHash);
            Assert.AreEqual(true, result);
            WalletAccount account = uut.GetAccount(testScriptHash);

            Assert.AreEqual(Contract.CreateSignatureRedeemScript(keyPair.PublicKey).ToScriptHash().ToAddress(ProtocolSettings.Default.AddressVersion), account.Address);
        }
示例#3
0
        public void TestGetAccounts()
        {
            Dictionary <UInt160, KeyPair> keys = new();

            byte[] privateKey = new byte[32];
            using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(privateKey);
            }
            KeyPair key = new(privateKey);

            keys.Add(Contract.CreateSignatureRedeemScript(key.PublicKey).ToScriptHash(), key);
            keys.Add(Contract.CreateSignatureRedeemScript(keyPair.PublicKey).ToScriptHash(), keyPair);
            uut.CreateAccount(key.PrivateKey);
            uut.CreateAccount(keyPair.PrivateKey);
            foreach (var account in uut.GetAccounts())
            {
                if (!keys.ContainsKey(account.ScriptHash))
                {
                    Assert.Fail();
                }
            }
        }
示例#4
0
 protected internal UInt160 CreateStandardAccount(ECPoint pubKey)
 {
     return(Contract.CreateSignatureRedeemScript(pubKey).ToScriptHash());
 }
示例#5
0
 protected bool CheckWitness(ExecutionEngine engine, ECPoint pubkey)
 {
     return(CheckWitness(engine, Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash()));
 }
示例#6
0
 private static bool CheckWitness(ApplicationEngine engine, ECPoint pubkey)
 {
     return(CheckWitness(engine, Contract.CreateSignatureRedeemScript(pubkey).ToScriptHash()));
 }