1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
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 <cryptofish82@gmail.com>) 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 <bitcoin-development@lists.sourceforge.net>;
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: <CALDrD5O0bn1xchKH=vs0FNDcdL24uUm3qs+1ERj24zw_VtVsHQ@mail.gmail.com>
From: Crypto Fish <cryptofish82@gmail.com>
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: <bitcoin-development.lists.sourceforge.net>
List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>,
<mailto:bitcoin-development-request@lists.sourceforge.net?subject=unsubscribe>
List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development>
List-Post: <mailto:bitcoin-development@lists.sourceforge.net>
List-Help: <mailto:bitcoin-development-request@lists.sourceforge.net?subject=help>
List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>,
<mailto:bitcoin-development-request@lists.sourceforge.net?subject=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
<div dir=3D"ltr"><div style=3D"font-family:arial,sans-serif;font-size:13px"=
>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?</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">Code works for this (1=
input, 2 outputs):</div><div style=3D"font-family:arial,sans-serif;font-si=
ze:13px">
<br></div><div style=3D"font-family:arial,sans-serif;font-size:13px">CTrans=
action(hash=3D01a3204517476812df2c2f77735a72a6d3e7eb8b9a5d5330ca433dd875fc4=
c3c, ver=3D1, vin.size=3D2, vout.size=3D4, nLockTime=3D0)</div><div style=
=3D"font-family:arial,sans-serif;font-size:13px">
=A0 =A0 CTxIn(COutPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80=
bb34245d3df84, 0), scriptSig=3D304502204cdfd276ff9c53bb)</div><div style=3D=
"font-family:arial,sans-serif;font-size:13px">=A0 =A0 CTxOut(nValue=3D4.000=
00000, scriptPubKey=3DOP_DUP OP_HASH160 b07e181ce438)</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 CTxOut(n=
Value=3D1.00000000, scriptPubKey=3DOP_DUP OP_HASH160 bf7484e469c8)</div><di=
v style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div styl=
e=3D"font-family:arial,sans-serif;font-size:13px">
Code doesn't work for this (2 input, 4 outputs):</div><div style=3D"fon=
t-family:arial,sans-serif;font-size:13px"><br></div><div style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">CTransaction(hash=3D01a3204517476812df2=
c2f77735a72a6d3e7eb8b9a5d5330ca433dd875fc4c3c, ver=3D1, vin.size=3D2, vout.=
size=3D4, nLockTime=3D0)</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 CTxIn(CO=
utPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80bb34245d3df84, 1=
), scriptSig=3D304502204aef3f393c273835)</div><div style=3D"font-family:ari=
al,sans-serif;font-size:13px">
=A0 =A0 CTxIn(COutPoint(6ee4049d6c75d6450e961446d28760207bd7036e2aa692afb80=
bb34245d3df84, 0), scriptSig=3D304502204cdfd276ff9c53bb)</div><div style=3D=
"font-family:arial,sans-serif;font-size:13px">=A0 =A0 CTxOut(nValue=3D4.000=
00000, scriptPubKey=3DOP_DUP OP_HASH160 bf7484e469c8)</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 CTxOut(n=
Value=3D491.00000000, scriptPubKey=3DOP_DUP OP_HASH160 0796b7f3430f)</div><=
div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 CTxOut(nV=
alue=3D4.00000000, scriptPubKey=3DOP_DUP OP_HASH160 b07e181ce438)</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 CTxOut(n=
Value=3D1.00000000, scriptPubKey=3DOP_DUP OP_HASH160 bf7484e469c8)</div><di=
v style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div styl=
e=3D"font-family:arial,sans-serif;font-size:13px">
Pseudo code showing working transaction:</div><div style=3D"font-family:ari=
al,sans-serif;font-size:13px"><br></div><div style=3D"font-family:arial,san=
s-serif;font-size:13px">=A0 =A0 // These are how the vout's are made</d=
iv><div style=3D"font-family:arial,sans-serif;font-size:13px">
=A0 =A0 CScript scriptPubKey;</div><div style=3D"font-family:arial,sans-ser=
if;font-size:13px">=A0 =A0 scriptPubKey.SetDestination(address); =A0 =A0</d=
iv><div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 CScri=
pt s;</div><div style=3D"font-family:arial,sans-serif;font-size:13px">
=A0 =A0 s << OP_DUP << OP_HASH160 << scriptPubKey.GetID()=
<< OP_EQUALVERIFY << OP_CHECKSIG;</div><div style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">=A0</div><div style=3D"font-family:aria=
l,sans-serif;font-size:13px">
=A0 =A0 CTxOut out(nValue, s);</div><div style=3D"font-family:arial,sans-se=
rif;font-size:13px">=A0</div><div style=3D"font-family:arial,sans-serif;fon=
t-size:13px">=A0 =A0 ---------------</div><div style=3D"font-family:arial,s=
ans-serif;font-size:13px">
<br></div><div style=3D"font-family:arial,sans-serif;font-size:13px"><br></=
div><div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 CTra=
nsaction txNew;</div><div style=3D"font-family:arial,sans-serif;font-size:1=
3px">=A0 =A0 txNew.vin.clear();</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 txNew.vo=
ut.clear();</div><div style=3D"font-family:arial,sans-serif;font-size:13px"=
><br></div><div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =
=A0 // vin and vout are already populated=A0</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 for(unsi=
gned int i =3D 0; i < vout.size(); i++){</div><div style=3D"font-family:=
arial,sans-serif;font-size:13px">=A0 =A0 =A0 =A0 txNew.vout.push_back(vout[=
i]);</div><div style=3D"font-family:arial,sans-serif;font-size:13px">
=A0 =A0 }</div><div style=3D"font-family:arial,sans-serif;font-size:13px">=
=A0 =A0=A0</div><div style=3D"font-family:arial,sans-serif;font-size:13px">=
=A0 =A0 //add all vins</div><div style=3D"font-family:arial,sans-serif;font=
-size:13px">=A0 =A0 for(unsigned int i =3D 0; i < vin.size(); i++){</div=
>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 =A0 =A0 =
txNew.vin.push_back(vin[i]);</div><div style=3D"font-family:arial,sans-seri=
f;font-size:13px">=A0 =A0 }</div><div style=3D"font-family:arial,sans-serif=
;font-size:13px">
<br></div><div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =
=A0 //add all vins</div><div style=3D"font-family:arial,sans-serif;font-siz=
e:13px">=A0 =A0 for(unsigned int i =3D 0; i < vin.size(); i++){</div><di=
v style=3D"font-family:arial,sans-serif;font-size:13px">
=A0 =A0 =A0 =A0 // this is signed with 2 separate keys for each vin</div><d=
iv style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 =A0 =A0 if=
(!SignSignature(*keystore, prevPubKey, txNew, i, int(SIGHASH_ALL|SIGHASH_AN=
YONECANPAY)))=A0</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 =A0 =A0 =
=A0 =A0 printf('signing failed!\n');</div><div style=3D"font-family=
:arial,sans-serif;font-size:13px"><br></div><div style=3D"font-family:arial=
,sans-serif;font-size:13px">
=A0 =A0 =A0 =A0 // I was told I might need to serialize the inputs? Not sur=
e how that would work</div><div style=3D"font-family:arial,sans-serif;font-=
size:13px">=A0 =A0 }</div><div style=3D"font-family:arial,sans-serif;font-s=
ize:13px"><br>
</div><div style=3D"font-family:arial,sans-serif;font-size:13px">=A0 =A0 Re=
layTransaction(txNew, txNew.Hash());</div><div style=3D"font-family:arial,s=
ans-serif;font-size:13px"><br></div><div style=3D"font-family:arial,sans-se=
rif;font-size:13px">
<br></div><div style=3D"font-family:arial,sans-serif;font-size:13px">---</d=
iv><div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><di=
v style=3D"font-family:arial,sans-serif;font-size:13px">CryptoFish</div></d=
iv>
--f46d044304b05efabe04f1d462f1--
|