bitpay / bitcore-lib

A pure and powerful JavaScript Bitcoin library
https://bitcore.io/
Other
611 stars 1.03k forks source link

Allow specific input index/indices in Transaction.sign #22

Open fanatid opened 8 years ago

fanatid commented 8 years ago

If you trying to sign transaction with a large number of inputs it's require a lot of time. bitcoinjs-lib has this possibility

braydonf commented 8 years ago

We should add some benchmarks here and optimize.

fanatid commented 8 years ago

@braydonf for what you want benchmark here?

braydonf commented 8 years ago

Something similar to https://github.com/bitpay/bitcore-lib/blob/master/benchmark/serialization.js for a transaction with many inputs.

Do you know where the bottleneck is at?

braydonf commented 8 years ago

Ah, sorry. Just realized that the solution was in the title. We should add benchmarks though.

braydonf commented 8 years ago

Since getSignatures and applySignatures are already being called on each input, it could make sense to do something such as this:

transaction.inputs[1].sign(privateKey);

Although, if the time it takes is the problem, it may be better to fix that instead.

fanatid commented 8 years ago

Add sign for every input is good idea. It can be used in Transaction.sign with specific input index/indices.