File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,17 @@ class Psbt {
143
143
return this ;
144
144
}
145
145
addInput ( inputData ) {
146
+ if (
147
+ arguments . length > 1 ||
148
+ ! inputData ||
149
+ inputData . hash === undefined ||
150
+ inputData . index === undefined
151
+ ) {
152
+ throw new Error (
153
+ `Invalid arguments for Psbt.addInput. ` +
154
+ `Requires single object with at least [hash] and [index]` ,
155
+ ) ;
156
+ }
146
157
checkInputsForPartialSig ( this . data . inputs , 'addInput' ) ;
147
158
const c = this . __CACHE ;
148
159
this . data . addInput ( inputData ) ;
@@ -163,6 +174,17 @@ class Psbt {
163
174
return this ;
164
175
}
165
176
addOutput ( outputData ) {
177
+ if (
178
+ arguments . length > 1 ||
179
+ ! outputData ||
180
+ outputData . value === undefined ||
181
+ ( outputData . address === undefined && outputData . script === undefined )
182
+ ) {
183
+ throw new Error (
184
+ `Invalid arguments for Psbt.addOutput. ` +
185
+ `Requires single object with at least [script or address] and [value]` ,
186
+ ) ;
187
+ }
166
188
checkInputsForPartialSig ( this . data . inputs , 'addOutput' ) ;
167
189
const { address } = outputData ;
168
190
if ( typeof address === 'string' ) {
Original file line number Diff line number Diff line change 311
311
"inputData" : {
312
312
"hash" : 42
313
313
},
314
- "exception" : " Error adding input. "
314
+ "exception" : " Invalid arguments for Psbt \\ .addInput \\ . Requires single object with at least \\ [hash \\ ] and \\ [index \\ ] "
315
315
},
316
316
{
317
317
"description" : " should be equal" ,
Original file line number Diff line number Diff line change @@ -182,6 +182,17 @@ export class Psbt {
182
182
}
183
183
184
184
addInput ( inputData : PsbtInputExtended ) : this {
185
+ if (
186
+ arguments . length > 1 ||
187
+ ! inputData ||
188
+ inputData . hash === undefined ||
189
+ inputData . index === undefined
190
+ ) {
191
+ throw new Error (
192
+ `Invalid arguments for Psbt.addInput. ` +
193
+ `Requires single object with at least [hash] and [index]` ,
194
+ ) ;
195
+ }
185
196
checkInputsForPartialSig ( this . data . inputs , 'addInput' ) ;
186
197
const c = this . __CACHE ;
187
198
this . data . addInput ( inputData ) ;
@@ -205,6 +216,18 @@ export class Psbt {
205
216
}
206
217
207
218
addOutput ( outputData : PsbtOutputExtended ) : this {
219
+ if (
220
+ arguments . length > 1 ||
221
+ ! outputData ||
222
+ outputData . value === undefined ||
223
+ ( ( outputData as any ) . address === undefined &&
224
+ ( outputData as any ) . script === undefined )
225
+ ) {
226
+ throw new Error (
227
+ `Invalid arguments for Psbt.addOutput. ` +
228
+ `Requires single object with at least [script or address] and [value]` ,
229
+ ) ;
230
+ }
208
231
checkInputsForPartialSig ( this . data . inputs , 'addOutput' ) ;
209
232
const { address } = outputData as any ;
210
233
if ( typeof address === 'string' ) {
You can’t perform that action at this time.
0 commit comments