Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1WBpIl-0003Ez-LV for bitcoin-development@lists.sourceforge.net; Fri, 07 Feb 2014 17:33:19 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.212.196 as permitted sender) client-ip=209.85.212.196; envelope-from=cryptofish82@gmail.com; helo=mail-wi0-f196.google.com; Received: from mail-wi0-f196.google.com ([209.85.212.196]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1WBpIk-0001Yr-NI for bitcoin-development@lists.sourceforge.net; Fri, 07 Feb 2014 17:33:19 +0000 Received: by mail-wi0-f196.google.com with SMTP id hm4so334294wib.3 for ; Fri, 07 Feb 2014 09:33:12 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.180.100.70 with SMTP id ew6mr665318wib.57.1391794392593; Fri, 07 Feb 2014 09:33:12 -0800 (PST) Received: by 10.194.62.141 with HTTP; Fri, 7 Feb 2014 09:33:12 -0800 (PST) Date: Fri, 7 Feb 2014 10:33:12 -0700 Message-ID: From: Crypto Fish To: bitcoin-development@lists.sourceforge.net Content-Type: multipart/alternative; boundary=f46d044304b05efabe04f1d462f1 X-Spam-Score: -0.3 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (cryptofish82[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (cryptofish82[at]gmail.com) 1.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1WBpIk-0001Yr-NI Subject: [Bitcoin-development] Multi Input/Output Transaction Problems X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Feb 2014 17:33:19 -0000 --f46d044304b05efabe04f1d462f1 Content-Type: text/plain; charset=ISO-8859-1 So, I'm having some problems getting a multi input/multi output transaction working. My code below works with 1 input and 2 output, but when adding more inputs/outputs the transaction gets rejected. I'm sure whatever I'm doing wrong in pretty simple, any ideas? Code works for this (1 input, 2 outputs): CTransaction(hash=01a3204517476812df2c2f77735a72a6d3e7eb8b9a5d5330ca433dd875fc4c3c, ver=1, vin.size=2, vout.size=4, nLockTime=0) CTxIn(COutPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80bb34245d3df84, 0), scriptSig=304502204cdfd276ff9c53bb) CTxOut(nValue=4.00000000, scriptPubKey=OP_DUP OP_HASH160 b07e181ce438) CTxOut(nValue=1.00000000, scriptPubKey=OP_DUP OP_HASH160 bf7484e469c8) Code doesn't work for this (2 input, 4 outputs): CTransaction(hash=01a3204517476812df2c2f77735a72a6d3e7eb8b9a5d5330ca433dd875fc4c3c, ver=1, vin.size=2, vout.size=4, nLockTime=0) CTxIn(COutPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80bb34245d3df84, 1), scriptSig=304502204aef3f393c273835) CTxIn(COutPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80bb34245d3df84, 0), scriptSig=304502204cdfd276ff9c53bb) CTxOut(nValue=4.00000000, scriptPubKey=OP_DUP OP_HASH160 bf7484e469c8) CTxOut(nValue=491.00000000, scriptPubKey=OP_DUP OP_HASH160 0796b7f3430f) CTxOut(nValue=4.00000000, scriptPubKey=OP_DUP OP_HASH160 b07e181ce438) CTxOut(nValue=1.00000000, scriptPubKey=OP_DUP OP_HASH160 bf7484e469c8) Pseudo code showing working transaction: // These are how the vout's are made CScript scriptPubKey; scriptPubKey.SetDestination(address); CScript s; s << OP_DUP << OP_HASH160 << scriptPubKey.GetID() << OP_EQUALVERIFY << OP_CHECKSIG; CTxOut out(nValue, s); --------------- CTransaction txNew; txNew.vin.clear(); txNew.vout.clear(); // vin and vout are already populated for(unsigned int i = 0; i < vout.size(); i++){ txNew.vout.push_back(vout[i]); } //add all vins for(unsigned int i = 0; i < vin.size(); i++){ txNew.vin.push_back(vin[i]); } //add all vins for(unsigned int i = 0; i < vin.size(); i++){ // this is signed with 2 separate keys for each vin if(!SignSignature(*keystore, prevPubKey, txNew, i, int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))) printf('signing failed!\n'); // I was told I might need to serialize the inputs? Not sure how that would work } RelayTransaction(txNew, txNew.Hash()); --- CryptoFish --f46d044304b05efabe04f1d462f1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
So, I'm having some problems getting a multi input/multi output transa= ction working. My code below works with 1 input and 2 output, but when addi= ng more inputs/outputs the transaction gets rejected. I'm sure whatever= I'm doing wrong in pretty simple, any ideas?

Code works for this (1= input, 2 outputs):

CTrans= action(hash=3D01a3204517476812df2c2f77735a72a6d3e7eb8b9a5d5330ca433dd875fc4= c3c, ver=3D1, vin.size=3D2, vout.size=3D4, nLockTime=3D0)
=A0 =A0 CTxIn(COutPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80= bb34245d3df84, 0), scriptSig=3D304502204cdfd276ff9c53bb)
=A0 =A0 CTxOut(nValue=3D4.000= 00000, scriptPubKey=3DOP_DUP OP_HASH160 b07e181ce438)
=A0 =A0 CTxOut(n= Value=3D1.00000000, scriptPubKey=3DOP_DUP OP_HASH160 bf7484e469c8)

Code doesn't work for this (2 input, 4 outputs):

CTransaction(hash=3D01a3204517476812df2= c2f77735a72a6d3e7eb8b9a5d5330ca433dd875fc4c3c, ver=3D1, vin.size=3D2, vout.= size=3D4, nLockTime=3D0)
=A0 =A0 CTxIn(CO= utPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80bb34245d3df84, 1= ), scriptSig=3D304502204aef3f393c273835)
=A0 =A0 CTxIn(COutPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80= bb34245d3df84, 0), scriptSig=3D304502204cdfd276ff9c53bb)
=A0 =A0 CTxOut(nValue=3D4.000= 00000, scriptPubKey=3DOP_DUP OP_HASH160 bf7484e469c8)
=A0 =A0 CTxOut(n= Value=3D491.00000000, scriptPubKey=3DOP_DUP OP_HASH160 0796b7f3430f)
<= div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 CTxOut(nV= alue=3D4.00000000, scriptPubKey=3DOP_DUP OP_HASH160 b07e181ce438)
=A0 =A0 CTxOut(n= Value=3D1.00000000, scriptPubKey=3DOP_DUP OP_HASH160 bf7484e469c8)

Pseudo code showing working transaction:

=A0 =A0 // These are how the vout's are made
=A0 =A0 CScript scriptPubKey;
=A0 =A0 scriptPubKey.SetDestination(address); =A0 =A0
=A0 =A0 CScri= pt s;
=A0 =A0 s << OP_DUP << OP_HASH160 << scriptPubKey.GetID()= << OP_EQUALVERIFY << OP_CHECKSIG;
=A0
=A0 =A0 CTxOut out(nValue, s);
=A0
=A0 =A0 ---------------


=A0 =A0 CTra= nsaction txNew;
=A0 =A0 txNew.vin.clear();
=A0 =A0 txNew.vo= ut.clear();

=A0 = =A0 // vin and vout are already populated=A0
=A0 =A0 for(unsi= gned int i =3D 0; i < vout.size(); i++){
=A0 =A0 =A0 =A0 txNew.vout.push_back(vout[= i]);
=A0 =A0 }
= =A0 =A0=A0
= =A0 =A0 //add all vins
=A0 =A0 for(unsigned int i =3D 0; i < vin.size(); i++){
=A0 =A0 =A0 =A0 = txNew.vin.push_back(vin[i]);
=A0 =A0 }

=A0 = =A0 //add all vins
=A0 =A0 for(unsigned int i =3D 0; i < vin.size(); i++){
=A0 =A0 =A0 =A0 // this is signed with 2 separate keys for each vin
=A0 =A0 =A0 =A0 if= (!SignSignature(*keystore, prevPubKey, txNew, i, int(SIGHASH_ALL|SIGHASH_AN= YONECANPAY)))=A0
=A0 =A0 =A0 =A0 = =A0 =A0 printf('signing failed!\n');

=A0 =A0 =A0 =A0 // I was told I might need to serialize the inputs? Not sur= e how that would work
=A0 =A0 }

=A0 =A0 Re= layTransaction(txNew, txNew.Hash());


---

CryptoFish
--f46d044304b05efabe04f1d462f1--