Commit Graph

563 Commits

Author SHA1 Message Date
Jonathan Chappelow
32b3ad1f33 txscript: remove obsolete requireMinimal comment
The requireMinimal flag for MakeScriptNum was removed in
84b65d049b but the description was left
in the comment for MakeScriptNum.  This removes that part of the docs.

Also expand on range error and fix code reference. In
d8306ee602, the error for out-of-range
changed from ErrNumberTooBig to ErrNumOutOfRange.
2022-09-29 11:18:51 -05:00
Dave Collins
ad02d8f300
multi: Go 1.19 doc comment formatting.
This modifies the entire repository to use the new formatting of doc
comments in the upcoming Go 1.19 release.

The primary motivating factors for this are:

- Builds check that files are formatted per gofmt and that will no
  longer be true as of Go 1.19 without these changes
- Separating all the updates into a single commit ensures these
  documentation only formatting changes do not clutter up diffs that
  actually change code

For the most part, the changes are just the automated changes suggested
by the Go 1.19 version of gofmt, but there are also a few cases where
the comments were reworded a bit to play nicely with the new formatting
requirements.

For example, the new version of gofmt reformats and collapses nested
lists where as the existing version does not.  Thus, instances of nested
lists have been changed to either eliminate them or use mixed markers
which produce expect results.
2022-07-30 04:08:58 -05:00
Dave Collins
7d59dd3b69
multi: Support module graph prune and lazy load.
This bumps the go directive for all of the modules provided by the
repository to 1.17 which will allow the new module graph pruning and
lazy loading capabilities introduced in Go 1.17 to be used once the
updated modules are released.

This means that, as described by the documentation, the go.mod files for
each module now include a separate require block that includes all of
the indirect dependencies
2022-03-25 07:20:01 -05:00
Dave Collins
bf841fe588
txscript: Reduce checkmultisig allocs.
Profiling allocations during an initial chain sync shows that a large
portion of the allocations due to the CHECKMULTISIG opcode are the
result of generating the list of public keys and signatures.

This eliminates those allocations as follows:

- Use slices into fixed-size stack-based backing arrays for the typical
  number of public keys and signatures
- Make the slice of signature info contiguous instead of pointers which
  not only eliminates the associated allocations, but also provides
  better cache locality
2022-03-17 05:23:13 -05:00
Dave Collins
9969b8f306
txscript: Support min int64 script num encoding.
This modifies the encoding logic for script numbers to support encoding
min int64s.  This was previously not supported since the type was not
public and it is not possible to achieve a min int64 within the context
of the script system itself due to the strict limits it imposes.

However, now that script numbers are exported for external use and
callers are not bound by the aforementioned strictness, it should be
possible to encode the entire range for completeness.

In practice, callers should never realistically need to encode the value
since the purpose of the type is to create encoded numbers for scripts
and the value in question will be rejected upon any attempt to use it as
a number when verifying scripts given it is out of range.
2022-01-01 03:14:42 -06:00
Dave Collins
1961854e1e
stdaddr: Limit v0 addr decode to max possible size.
This modifies DecodeAddressV0 to reject any attempts to decode strings
that are larger than the max possible size early since there is no
reason to waste time and memory doing the base 58 decode when it is
guaranteed to be invalid anyway.

It also adds an associated test to ensure proper functionality.
2022-01-01 03:09:11 -06:00
Dave Collins
cc74183435
stdscript: Reject multisig neg thresholds.
This modifies the MultiSigScriptV0 convenience func for creating a
multisig script to return an error if the caller improperly calls it
with a negative threshold.
2022-01-01 01:22:07 -06:00
Dave Collins
55fb28cbbd
txscript: Prepare v4.0.0.
This updates the txscript module dependencies, the copyright year in the
files modified since the previous release, and serves as a base for
txscript/v4.0.0.

The updated direct dependencies in this commit are as follows:

- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/chaincfg/v3@v3.1.0
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.2
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.0.1
- github.com/decred/dcrd/wire@v1.5.0
- github.com/decred/slog@v1.2.0

The full list of updated direct dependencies since the previous
txscript/v3.0.0 release are as follows:

- github.com/dchest/siphash@v1.2.2
- github.com/decred/base58@v1.0.3
- github.com/decred/dcrd/chaincfg/chainhash@v1.0.3
- github.com/decred/dcrd/chaincfg/v3@v3.1.0
- github.com/decred/dcrd/crypto/blake256@v1.0.0
- github.com/decred/dcrd/dcrec/edwards/v2@v2.0.2
- github.com/decred/dcrd/dcrec/secp256k1/v4@v4.0.1
- github.com/decred/dcrd/wire@v1.5.0
- github.com/decred/slog@v1.2.0

The following direct dependencies are no longer required as compared to
the previous txscript/v3.0.0 release:

- github.com/decred/dcrd/dcrutil/v3

Finally, all modules in the repository that depend on txscript are
tidied to ensure they are updated to use the latest versions hoisted
forward as a result.
2021-11-18 23:14:01 -06:00
Dave Collins
b1b9a86da0
stdscript: Add extract v0 stake-tagged p2sh bench.
BenchmarkExtractStakeScriptHashV0
---------------------------------
v0_complex_non_standard       226793582   5.253 ns/op
v0_stake_submission_p2sh      372232682   3.233 ns/op
v0_stake_gen_p2sh             305602378   3.979 ns/op
v0_stake_revoke_p2sh          201691552   5.064 ns/op
v0_stake_change_p2sh          209401243   5.687 ns/op
v0_treasury_generation_p2sh   221794405   5.419 ns/op
2021-11-18 23:02:42 -06:00
Dave Collins
2e09c16c56
stdscript: Add v0 stake-tagged p2sh extract.
This adds support for directly extracting the script hash from standard
version 0 stake-tagged pay-to-script-hash scripts along with full test
coverage.

While all of this data can be extracted from each individual type, it
can be more convenient for callers who treat all script hashes as the
same entity which is the case for many applications.
2021-11-18 23:02:33 -06:00
Dave Collins
a81014df3c
stdscript: Add extract v0 stake-tagged p2pkh bench.
BenchmarkExtractStakePubKeyHashV0
---------------------------------
v0_complex_non_standard-16                        229676676   5.139 ns/op
v0_stake_submission_p2pkh-ecdsa-secp256k1-16      335241789   3.531 ns/op
v0_stake_gen_p2pkh-ecdsa-secp256k1-16             268142942   4.517 ns/op
v0_stake_revoke_p2pkh-ecdsa-secp256k1-16          244045095   4.908 ns/op
v0_stake_change_p2pkh-ecdsa-secp256k1-16          220275314   5.441 ns/op
v0_treasury_generation_p2pkh-ecdsa-secp256k1-16   197104339   6.086 ns/op
2021-11-18 23:02:29 -06:00
Dave Collins
d4f5338af0
stdscript: Add v0 stake-tagged p2pkh extract.
This adds support for directly extracting the public key hash from
standard version 0 stake-tagged pay-to-pubkey-hash scripts along with
full test coverage.

While all of this data can be extracted from each individual type, it
can be more convenient for callers who treat all public key hashes as
the same entity which is the case for many applications.
2021-11-18 23:02:05 -06:00
Dave Collins
c0fe15fa0e
stdaddr: Use txscript for opcode definitions.
This modifies the code to use the opcode definitions in txscript now
that the previous cyclic dependency no longer applies since txscript no
longer depends on stdaddr.
2021-11-18 13:15:06 -06:00
Dave Collins
67d1e95792
txscript: Remove unused ErrTooMuchNullData.
This removes ErrTooMuchNullData and its associated stringer test since
it is no longer used by anything in the repository.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:42 -06:00
Dave Collins
2f193bda49
txscript: Remove unused ErrTooManyRequiredSigs.
This removes ErrTooManyRequiredSigs and its associated stringer test
since it is no longer used by anything in the repository.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:42 -06:00
Dave Collins
bceeecad82
txscript: Remove unused ErrNotMultisigScript.
This removes ErrNotMultisigScript and its associated stringer test since
it is no longer used by anything in the repository.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:41 -06:00
Dave Collins
1555bc4e31
txscript: Remove unused ScriptClass.
This removes ScriptClass and its associated tests since it is no longer
used by anything in the repository and is now available via
stdscript.ScriptType.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:40 -06:00
Dave Collins
ba9df917eb
txscript: Remove unused MaxDataCarrierSize.
This removes MaxDataCarrierSize since it is no longer used by anything
in the repository and is now available via
stdscript.MaxDataCarrierSizeV0.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:40 -06:00
Dave Collins
edc646cb0d
txscript: Remove unused isStandardAltSignatureType.
This removes isStandardAltSignatureType since it is no longer used by
anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:39 -06:00
Dave Collins
f41ce67e6d
txscript: Remove unused extractPubKeyHashAltDetails.
This removes extractPubKeyHashAltDetails since it is no longer used by
anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:39 -06:00
Dave Collins
6260335f9c
txscript: Remove unused isPubKeyHashAltScript.
This removes isPubKeyHashAltScript along with its benchmark since it is
no longer used by anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:38 -06:00
Dave Collins
cc494923d4
txscript: Remove unused extractCompressedPubKey.
This removes extractCompressedPubKey since it is no longer used by
anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:37 -06:00
Dave Collins
8565a3b356
txscript: Remove unused extractUncompressedPubKey.
This removes extractUncompressedPubKey since it is no longer used by
anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:37 -06:00
Dave Collins
838adbc717
txscript: Remove unused extractPubKey.
This removes extractPubKey since it is no longer used by anything in the
package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:36 -06:00
Dave Collins
78ebc66740
txscript: Remove unused isPubKeyScript.
This removes isPubKeyScript along with its benchmark since it is no
longer used by anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:35 -06:00
Dave Collins
9e754a3ad1
txscript: Remove unused extractPubKeyAltDetails.
This removes extractPubKeyAltDetails since it is no longer used by
anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:34 -06:00
Dave Collins
2903b61051
txscript: Remove unused isPubKeyAltScript.
This removes isPubKeyAltScript along with its benchmark since it is no
longer used by anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:33 -06:00
Dave Collins
7cb5314b44
txscript: Remove unused extractPubKeyHash.
This removes extractPubKeyHash since it is no longer used by anything in
the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:31 -06:00
Dave Collins
d96ae229b4
txscript: Remove unused isNullDataScript.
This removes isNullDataScript along with its benchmark since it is no
longer used by anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:30 -06:00
Dave Collins
556b21e8db
txscript: Remove unused extractStakePubKeyHash.
This removes extractStakePubKeyHash since it is no longer used by
anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:29 -06:00
Dave Collins
af5329ffb0
txscript: Remove unused extractStakeScriptHash.
This removes extractStakeScriptHash since it is no longer used by
anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:28 -06:00
Dave Collins
c508b538d2
txscript: Remove unused isStakeSubmissionScript.
This removes isStakeSubmissionScript along with its benchmark since it
is no longer used by anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:28 -06:00
Dave Collins
89421e5d67
txscript: Remove unused isStakeGenScript.
This removes isStakeGenScript along with its benchmark since it is no
longer used by anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:27 -06:00
Dave Collins
695077bdd2
txscript: Remove unused isStakeRevocationScript.
This removes isStakeRevocationScript along with its benchmark since it
is no longer used by anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:27 -06:00
Dave Collins
8fac63e2bf
txscript: Remove unused isPubKeyHashScript.
This removes isPubKeyHashScript along with its benchmark since it is no
longer used by anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:26 -06:00
Dave Collins
cfebbab0de
txscript: Remove unused isStakeChangeScript.
This removes isStakeChangeScript along with its benchmark since it is no
longer used by anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:26 -06:00
Dave Collins
abdf57c628
txscript: Remove unused extractMultisigScriptDetails.
This removes extractMultisigScriptDetails since it is no longer used by
anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:25 -06:00
Dave Collins
d4e3a1624b
txscript: Remove unused isTreasuryAddScript.
This removes isTreasuryAddScript since it is no longer used by anything
in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:24 -06:00
Dave Collins
6114d62e30
txscript: Remove unused pubKeyHashToAddrs.
This removes pubKeyHashToAddrs since it is no longer used by anything in
the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:24 -06:00
Dave Collins
67b9252425
txscript: Remove unused scriptHashToAddrs.
This removes scriptHashToAddrs since it is no longer used by anything in
the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:23 -06:00
Dave Collins
611a7e2a99
txscript: Remove unused ExtractPkScriptAddrs.
This removes ExtractPkScriptAddrs and its associated tests, benchmarks,
and example since it is no longer used by anything in the repository
and is now available via stdscript.ExtractAddrs.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:23 -06:00
Dave Collins
4d09bcb68e
txscript: Remove unused isMultisigScript.
This removes isMultisigScript since it is no longer used by anything in
the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:22 -06:00
Dave Collins
54734a711c
txscript: Remove unused isTreasurySpendScript.
This removes isTreasurySpendScript since it is no longer used by
anything in the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:21 -06:00
Dave Collins
64b0d981ee
txscript: Remove unused typeOfScript.
This removes typeOfScript since it is no longer used by anything in
the package.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:21 -06:00
Dave Collins
828267450c
txscript: Remove unused GetStakeOutSubclass.
This removes GetScriptClass since it is no longer used by anything in
the repository and is also no longer needed since the relevant
information is now available via the more fine grained script types
of stdscript.DetermineScriptType.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:20 -06:00
Dave Collins
526f3488cb
txscript: Remove unused GetScriptClass.
This removes GetScriptClass and its associated tests and benchmarks
since it is no longer used by anything in the repository and is now
available via stdscript.DetermineScriptType.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:20 -06:00
Dave Collins
58ada7c61b
txscript: Remove unused ExtractPkScriptAltSigType.
This removes ExtractPkScriptAltSigType and its associated benchmark
since it is no longer used by anything in the repository and is now
available via stdscript.ExtractPubKeyAltDetailsV0 or
stdscript.ExtractPubKeyHashAltDetailsV0 although it typically is no
longer needed since stdscript has more fine-grained script types.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:19 -06:00
Dave Collins
99c2598733
txscript: Remove unused IsMultisigSigScript.
This removes IsMultisigSigScript and its associated benchmarks since it
is no longer used by anything in the repository and is now available via
stdscript.IsMultiSigSigScript.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:18 -06:00
Dave Collins
b1c0669ae5
txscript: Remove unused IsMultisigScript.
This removes IsMultisigScript and its associated benchmarks since it is
no longer used by anything in the repository and is now available via
stdscript.IsMultiSigScript.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:17 -06:00
Dave Collins
b16fafaee8
txscript: Remove unused CalcMultiSigStats.
This removes CalcMultiSigStats and its associated tests and benchmark
since it is no longer used by anything in the repository and is now
available via stdscript.ExtractMultiSigScriptDetailsV0.

This is part of a series of commits to remove all code related to
standard scripts from txscript.
2021-11-18 12:55:16 -06:00