-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImmutableTransaction/Transaction Split #1224
Comments
When creating a transaction with unrecognized previous output script, most of the methods will not be usable as abstract methods are invoked: https://github.com/bitpay/bitcore/blob/master/lib/transaction/input/input.js#L162. I'm wondering if we should fail earlier, and then use ImmutableTransaction for all of the other cases. |
I'd love to see first a better deserialization of inputs. Right now, deserialization does no attempt to read signatures or script type: bitcore/lib/transaction/transaction.js Line 306 in c671a97
calls bitcore/lib/transaction/input/input.js Line 91 in c671a97
|
After adding benchmarks for transaction serialization, there wasn't a large performance (although there was around a 30%) improvement from separate constructors for Transaction or Block. |
Serialization/deserialization of the current Transaction instances will lose information that is needed for many of the methods to work correctly. Separating Transaction into two constructors should help with clarity of supported methods when creating new transactions, and with performance with reading transactions from a block (such as when blockchain syncing).
ImmutableTransaction
This transaction would only have methods that will work from a transaction serialized from a block (without previous output information). All of the properties such as inputs, outputs can be read as objects, and a serialized copy of the transaction will be cached such that calculating the
id
andhash
doesn't need to regenerate the serialized buffer. Instances of transactions within a block will use this constructor, since these transactions are not mutable. Serialization will be a hexa buffer, as per the Bitcoin protocol specification.Transaction
This constructor would instantiate a mutable instance (the current Bitcore Transaction constructor). However, with the change that serialization is only JSON that includes all previous output information. Methods such as
getFee()
,getSendingAddresses()
,getSendingAddresses()
,sign()
,to()
,from()
,change()
, and etc. all work as expected. When this type of transaction needs to be broadcast to the network, serialization checks (as is current) can be made and then an instance ofImmutableTransaction
can be instantiated for the final serialization.Related Issues:
The text was updated successfully, but these errors were encountered: