Exemple #1
0
        public static bool LockUnspent()
        {
            Console.WriteLine("Starting LockUnspent tests...");

            Bitcoind.RawTxInput[] inputs1 = new Bitcoind.RawTxInput[1];
            Bitcoind.RawTxInput   input1  = new Bitcoind.RawTxInput();
            input1.txID = "fff17832d351c12476dc3d6f902fd2e0666992135ffe49ac343d9db15dfcddf7";
            input1.vout = "0";
            inputs1 [0] = input1;

            Bitcoind.RawTxInput[] inputs2 = new Bitcoind.RawTxInput[2];
            Bitcoind.RawTxInput   input2  = new Bitcoind.RawTxInput();
            input2.txID = "f7d882aea4204b2dbe2d3941c1ee280c7c34551f005f5e7ef52f4c19cfea3db8";
            input2.vout = "0";
            inputs2 [0] = input1;
            inputs2 [1] = input2;

            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent(false));
            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent(true));
            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent(false, inputs1));
            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent(true, inputs1));
            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent(false, inputs2));
            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent(true, inputs2));

            return(true);
        }
Exemple #2
0
        public static bool CreateRawTransaction()
        {
            Console.WriteLine("Starting CreateRawTransaction tests...");

            // NOTE: scriptPubKey and redeemScript are not being tested in this case.

            Bitcoind.RawTxInput[] inputs1 = new Bitcoind.RawTxInput[1];
            Bitcoind.RawTxInput   input1  = new Bitcoind.RawTxInput();
            input1.txID = "fff17832d351c12476dc3d6f902fd2e0666992135ffe49ac343d9db15dfcddf7";
            input1.vout = "0";
            inputs1 [0] = input1;

            Bitcoind.RawTxInput[] inputs2 = new Bitcoind.RawTxInput[2];
            Bitcoind.RawTxInput   input2  = new Bitcoind.RawTxInput();
            input2.txID = "e69899e5bd2020b99c67b258e5d56ca5c091c9b065f412381ce44a9e438721c1";
            input2.vout = "1";
            inputs2 [0] = input1;
            inputs2 [1] = input2;

            Bitcoind.PayToAddress[] outputs1 = new Bitcoind.PayToAddress[1];
            Bitcoind.PayToAddress   output1  = new Bitcoind.PayToAddress();
            output1.address = "mjkTKcq27UHMoydoQPrq74fCgyBZ5DCAwf";
            output1.amount  = "1.5";
            outputs1 [0]    = output1;

            Bitcoind.PayToAddress[] outputs2 = new Bitcoind.PayToAddress[2];
            Bitcoind.PayToAddress   output2  = new Bitcoind.PayToAddress();
            output2.address = "miKXJCSnAYyMNPX1emfd7QGXdCFTJRm9Bi";
            output2.amount  = "10.123456";
            outputs2 [0]    = output1;
            outputs2 [1]    = output2;

            // Test 1 tx with 1 output
            _rawTx1To1 = Bitcoind.CreateRawTransaction(inputs1, outputs1);
            if (_rawTx1To1 == null || _rawTx1To1.Length == 0)
            {
                return(false);
            }
            // Test 1 tx with 2 output
            _rawTx1To2 = Bitcoind.CreateRawTransaction(inputs1, outputs2);
            if (_rawTx1To2 == null || _rawTx1To2.Length == 0)
            {
                return(false);
            }
            // Test 2 tx with 1 output
            _rawTx2To1 = Bitcoind.CreateRawTransaction(inputs2, outputs1);
            if (_rawTx2To1 == null || _rawTx2To1.Length == 0)
            {
                return(false);
            }
            // Test 2 tx with 2 output
            _rawTx2To2 = Bitcoind.CreateRawTransaction(inputs2, outputs2);
            if (_rawTx2To2 == null || _rawTx2To2.Length == 0)
            {
                return(false);
            }
            return(true);
        }
Exemple #3
0
        public static bool SignRawTransaction()
        {
            Console.WriteLine("Starting SignRawTransaction tests...");

            // Note that this depends on CreateRawTransaction having been run.

            // Was originally going to use this, but signrawtransaction works so well with multisig...
//			Bitcoind.RawTxInput[] inputs1 = new Bitcoind.RawTxInput[1];
//			Bitcoind.RawTxInput input1 = new Bitcoind.RawTxInput ();
//			input1.txID = "fff17832d351c12476dc3d6f902fd2e0666992135ffe49ac343d9db15dfcddf7";
//			input1.vout = "0";
//			inputs1 [0] = input1;
//
//			Bitcoind.RawTxInput[] inputs2 = new Bitcoind.RawTxInput[2];
//			Bitcoind.RawTxInput input2 = new Bitcoind.RawTxInput ();
//			input2.txID = "e69899e5bd2020b99c67b258e5d56ca5c091c9b065f412381ce44a9e438721c1";
//			input2.vout = "1";
//			inputs2 [0] = input1;
//			inputs2 [1] = input2;
//
//			string[] inputs2PrivKeys = new string[2];
//			inputs2PrivKeys[0] = "cQ1nxdyfCY19WqoQQctArRga77xsneJPieRzuku4d7rjyTXT6Cmt";
//			inputs2PrivKeys[1] = "cVJpaLpFVceG3WERxShJGs81YhcSunucwd7j1Xh6nRPhMKF6tkAd";

            string multiSigTxHex = "0100000001cd13a17b390f450bdebd546095e9b8cb9e5985285933ab171379372686d807610000000000ffffffff0140420f00000000001976a91488260a05398e905853eb103825538d4380e07a2388ac00000000";

            Bitcoind.RawTxInput[] multiSigInputs = new Bitcoind.RawTxInput[1];
            Bitcoind.RawTxInput   multiSigInput  = new Bitcoind.RawTxInput();
            multiSigInput.txID         = "6107d8862637791317ab33592885599ecbb8e9956054bdde0b450f397ba113cd";
            multiSigInput.vout         = "0";
            multiSigInput.scriptPubKey = "a914bc9fd4193f6bff24df8450d7f326ea8b04bc1cb387";
            multiSigInput.redeemScript = "522103be117fab1593c1f5aa43353df54a0920fc699f089e872f36a40599688f566a472102558f523c7b6c97e10d89348c9b93b7ee7d860f62027f932eb150d4ba6e41c27821032973a0a39b810f1b3b351241e1ebe71ab21159e2068ddc352bb19d1c4f6f3d9553ae";
            multiSigInputs [0]         = multiSigInput;

            string[] multiSigPrivKeys =
            {
                "cToctw27wEp97fUzQ1VHih4qAzyAkp2Nq8MiQYABbnpkm36f6m1F",
                "cUjMgRmsRp9s5fSqXzyjZiTFddxa62hLdeJdWceD4BTm6gQY2geQ"
            };

            string signedTx1To1 = Bitcoind.SignRawTransaction(_rawTx1To1);
            string signedTx1To2 = Bitcoind.SignRawTransaction(multiSigTxHex, multiSigInputs);
            string signedTx2To1 = Bitcoind.SignRawTransaction(multiSigTxHex, multiSigInputs, multiSigPrivKeys);
            string signedTx2To2 = Bitcoind.SignRawTransaction(multiSigTxHex, multiSigInputs, multiSigPrivKeys, Bitcoind.SigHashType.AllOrAnyoneCanPay);

            return(true);
        }
Exemple #4
0
        public static bool CreateRawTransaction()
        {
            Console.WriteLine ("Starting CreateRawTransaction tests...");

            // NOTE: scriptPubKey and redeemScript are not being tested in this case.

            Bitcoind.RawTxInput[] inputs1 = new Bitcoind.RawTxInput[1];
            Bitcoind.RawTxInput input1 = new Bitcoind.RawTxInput ();
            input1.txID = "fff17832d351c12476dc3d6f902fd2e0666992135ffe49ac343d9db15dfcddf7";
            input1.vout = "0";
            inputs1 [0] = input1;

            Bitcoind.RawTxInput[] inputs2 = new Bitcoind.RawTxInput[2];
            Bitcoind.RawTxInput input2 = new Bitcoind.RawTxInput ();
            input2.txID = "e69899e5bd2020b99c67b258e5d56ca5c091c9b065f412381ce44a9e438721c1";
            input2.vout = "1";
            inputs2 [0] = input1;
            inputs2 [1] = input2;

            Bitcoind.PayToAddress[] outputs1 = new Bitcoind.PayToAddress[1];
            Bitcoind.PayToAddress output1 = new Bitcoind.PayToAddress ();
            output1.address = "mjkTKcq27UHMoydoQPrq74fCgyBZ5DCAwf";
            output1.amount = "1.5";
            outputs1 [0] = output1;

            Bitcoind.PayToAddress[] outputs2 = new Bitcoind.PayToAddress[2];
            Bitcoind.PayToAddress output2 = new Bitcoind.PayToAddress ();
            output2.address = "miKXJCSnAYyMNPX1emfd7QGXdCFTJRm9Bi";
            output2.amount = "10.123456";
            outputs2 [0] = output1;
            outputs2 [1] = output2;

            // Test 1 tx with 1 output
            _rawTx1To1 = Bitcoind.CreateRawTransaction (inputs1, outputs1);
            if (_rawTx1To1 == null || _rawTx1To1.Length == 0)
                return false;
            // Test 1 tx with 2 output
            _rawTx1To2 = Bitcoind.CreateRawTransaction (inputs1, outputs2);
            if (_rawTx1To2 == null || _rawTx1To2.Length == 0)
                return false;
            // Test 2 tx with 1 output
            _rawTx2To1 = Bitcoind.CreateRawTransaction (inputs2, outputs1);
            if (_rawTx2To1 == null || _rawTx2To1.Length == 0)
                return false;
            // Test 2 tx with 2 output
            _rawTx2To2 = Bitcoind.CreateRawTransaction (inputs2, outputs2);
            if (_rawTx2To2 == null || _rawTx2To2.Length == 0)
                return false;
            return true;
        }
Exemple #5
0
        public static bool SignRawTransaction()
        {
            Console.WriteLine ("Starting SignRawTransaction tests...");

            // Note that this depends on CreateRawTransaction having been run.

            // Was originally going to use this, but signrawtransaction works so well with multisig...
            //			Bitcoind.RawTxInput[] inputs1 = new Bitcoind.RawTxInput[1];
            //			Bitcoind.RawTxInput input1 = new Bitcoind.RawTxInput ();
            //			input1.txID = "fff17832d351c12476dc3d6f902fd2e0666992135ffe49ac343d9db15dfcddf7";
            //			input1.vout = "0";
            //			inputs1 [0] = input1;
            //
            //			Bitcoind.RawTxInput[] inputs2 = new Bitcoind.RawTxInput[2];
            //			Bitcoind.RawTxInput input2 = new Bitcoind.RawTxInput ();
            //			input2.txID = "e69899e5bd2020b99c67b258e5d56ca5c091c9b065f412381ce44a9e438721c1";
            //			input2.vout = "1";
            //			inputs2 [0] = input1;
            //			inputs2 [1] = input2;
            //
            //			string[] inputs2PrivKeys = new string[2];
            //			inputs2PrivKeys[0] = "cQ1nxdyfCY19WqoQQctArRga77xsneJPieRzuku4d7rjyTXT6Cmt";
            //			inputs2PrivKeys[1] = "cVJpaLpFVceG3WERxShJGs81YhcSunucwd7j1Xh6nRPhMKF6tkAd";

            string multiSigTxHex = "0100000001cd13a17b390f450bdebd546095e9b8cb9e5985285933ab171379372686d807610000000000ffffffff0140420f00000000001976a91488260a05398e905853eb103825538d4380e07a2388ac00000000";
            Bitcoind.RawTxInput[] multiSigInputs = new Bitcoind.RawTxInput[1];
            Bitcoind.RawTxInput multiSigInput = new Bitcoind.RawTxInput ();
            multiSigInput.txID = "6107d8862637791317ab33592885599ecbb8e9956054bdde0b450f397ba113cd";
            multiSigInput.vout = "0";
            multiSigInput.scriptPubKey = "a914bc9fd4193f6bff24df8450d7f326ea8b04bc1cb387";
            multiSigInput.redeemScript = "522103be117fab1593c1f5aa43353df54a0920fc699f089e872f36a40599688f566a472102558f523c7b6c97e10d89348c9b93b7ee7d860f62027f932eb150d4ba6e41c27821032973a0a39b810f1b3b351241e1ebe71ab21159e2068ddc352bb19d1c4f6f3d9553ae";
            multiSigInputs [0] = multiSigInput;

            string[] multiSigPrivKeys = {
                "cToctw27wEp97fUzQ1VHih4qAzyAkp2Nq8MiQYABbnpkm36f6m1F",
                "cUjMgRmsRp9s5fSqXzyjZiTFddxa62hLdeJdWceD4BTm6gQY2geQ"
            };

            string signedTx1To1 = Bitcoind.SignRawTransaction (_rawTx1To1);
            string signedTx1To2 = Bitcoind.SignRawTransaction (multiSigTxHex, multiSigInputs);
            string signedTx2To1 = Bitcoind.SignRawTransaction (multiSigTxHex, multiSigInputs, multiSigPrivKeys);
            string signedTx2To2 = Bitcoind.SignRawTransaction (multiSigTxHex, multiSigInputs, multiSigPrivKeys, Bitcoind.SigHashType.AllOrAnyoneCanPay);

            return true;
        }
Exemple #6
0
        public static bool LockUnspent()
        {
            Console.WriteLine ("Starting LockUnspent tests...");

            Bitcoind.RawTxInput[] inputs1 = new Bitcoind.RawTxInput[1];
            Bitcoind.RawTxInput input1 = new Bitcoind.RawTxInput ();
            input1.txID = "fff17832d351c12476dc3d6f902fd2e0666992135ffe49ac343d9db15dfcddf7";
            input1.vout = "0";
            inputs1 [0] = input1;

            Bitcoind.RawTxInput[] inputs2 = new Bitcoind.RawTxInput[2];
            Bitcoind.RawTxInput input2 = new Bitcoind.RawTxInput ();
            input2.txID = "f7d882aea4204b2dbe2d3941c1ee280c7c34551f005f5e7ef52f4c19cfea3db8";
            input2.vout = "0";
            inputs2 [0] = input1;
            inputs2 [1] = input2;

            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent (false));
            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent (true));
            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent (false, inputs1));
            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent (true, inputs1));
            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent (false, inputs2));
            Console.WriteLine("LockUnspent: " + Bitcoind.LockUnspent (true, inputs2));

            return true;
        }