This forces the UTXO cache to flush to the database when the chain just
latched to current. This ensures that the full UTXO set is always
flushed to the database when the chain becomes current, which allows for
fetching up-to-date UTXO set stats.
The behavior before these changes is that the UTXO cache will not be
forced to flush to the database until a block is connected AFTER the
chain is already latched to current. Therefore, if you fetch UTXO stats
when the chain is current but the next block has not been connected yet,
the UTXO stats may not be up to date.
This adds explicit test cases for the consensus-specific
isAnyKindOfScriptHash method of the engine instead of using the script
class tests which are only intended for use by standardness code
This adds explicit test cases for the consensus-specific
IsPayToScriptHash func instead of using the script class tests which are
only intended for use by standardness code.
This removes PushedData along with its associated test and benchmark
from txscript since it is no longer used by anything and hasn't been for
quite some time due to the introduction of the zero allocation script
tokenizer which allows it to be done by callers more efficiently.
This removes IsStakeChangeScriptScript from txscript since it is no
longer used as it was only used by the new treasury code from stake
which should have been using its internal consensus funcs as is now the
case.
This removes IsPubKeyHashScript from txscript since it is no longer used
as it was only used by the new treasury code from stake which should
have been using its internal consensus funcs as is now the case.
This separates the test code related to parsing scripts using the
human-readable short form used throughout the tests into a separate file
so it can more easily be copied into other packages where it might be
useful for the tests as well. Allowing it to be copied is preferred to
making it part of the public API of some package since it is an ad-hoc
format and it is not possible to access test-specific code across
package boundaries without making it part of the actual public API.
This moves the GenerateSSGenVotes method to script.go since it is used
in consensus code and therefore should not be in standard.go which is
only intended for standardness code.
It also moves the associated test to script_test.go to match and does
some other misc cleanup such as improving the comments and tests for
consistency.
This moves the GenerateSSGenBlockRef method to script.go since it is
used in consensus code and therefore should not be in standard.go which
is only intended for standardness code.
It also moves the associated test to script_test.go to match and does
some other misc cleanup such as improving the comments and tests for
consistency.
This moves the ContainsStakeOpCodes method to script.go since it is used
in consensus code and therefore should not be in standard.go which is
only intended for standardness code.
This ensures the recently-added script version field of
types.ScriptPubKeyResult is set in the various RPCs that produce raw
transaction results. Namely, getrawtransaction, decoderawtransaction,
searchrawtransaction, and getblock (with the verbose tx flag set).
Note that this is a duplicate of the types.Vout.Version field.
This removes TODO comments in CheckSSRtx that are no longer needed since
the checks that are referred to are already handled in validate.go (in
the checkRevocationInputs and checkTicketRedeemerCommitments functions).
This removes TODO comments in CheckSSGenVotes that are no longer needed
since the checks that are referred to are already handled in validate.go
(in the checkVoteInputs and checkTicketRedeemerCommitments functions).
This updates the CheckSSRtx function comment to refer to the correct
output indexes from the input ticket transaction. It also updates the
comment to refer to SSRtx outputs rather than SSGen outputs.
This adds a comment to MaxOutputsPerSSGen indicating that if the
treasury agenda is active, an OP_RETURN TV (treasury vote) output is
additionally included in the last position when voting on a treasury
spend.
The MaxOutputsPerSSGen value does NOT account for this output, and
should technically be increased by 1, but since the treasury agenda is
already active this cannot be updated without a consensus vote.
This modifies the version 2 block filters in gcs to avoid using
standardness code since they are part of consensus code through header
commitments and therefore must not change even though the policy
regarding standardness can change.
It accomplishes the change by making use of the consensus-specific
script identification methods available via the stake package.
This modifies the treasury code in blockchain which enforces the
treasury generation spending maturity to avoid using standardness code
since it is consensus level code which means it must not change even
though the policy regarding standardness can change.
This adds a method to stake which allow treasury generation scripts that
are enforced by consensus to be identified via a consensus-specific
method versus relying on the policy-based variant that is subject to
change.
This is consistent with the other consensus-enforced stake-related
scripts exported from the package.
This removes the unnecessary OP_TADD coinbase maturity check because
OP_TADD is not a spendable utxo and therefore it can never have a
maturity applied to it. Recall that treasurybase and treasury add stake
transactions are the only place an OP_TADD is valid and in both cases
they result in increasing the balance of the treasury account and are
never directly spendable.
This modifies the treasury code in stake to avoid using standardness
code since it is consensus level code which mean it must not change even
though the policy regarding standardness can change.
The consensus-specific methods are all already available in the stake
package, so the code is merely updated to use them instead.
An overview of the changes follows:
- Introduce an exported constant for the max data carrier size allowed
in stake transactions set to match the current standardness value
since that is now part of consensus for them
- Modify the calls to txscript.GetScriptClass used for determining null
data scripts to use consensus-specific IsNullDataScript method
- Use the consensus-specific methods for the following:
- IsStakeChangeScript
- isPubKeyHashScript
- isScriptHashScript
This modifies the TicketsWithAddress query method in blockchain to
accept the more specific stdaddr.StakeAddress since only stake-capable
addresses can be used in tickets and modifies the logic to compare the
expected voting rights script and associated script version directly
instead of extracting and comparing encoded addresses. It also updates
the callers and plumbing in rpcserver accordingly as well as adds a test
for the new non-stake address error in the RPC handler.
Not only is this approach more efficient, it also removes the reliance
on address extraction which in turn removes the need for the flag which
specifies whether or not the treasury is active.
This adds an example for extracting the script hash from a
pay-to-script-hash script.
This part of a series of commits to fully implement the stdscript
package.
This adds an example for extracting the public key hash from a
p2pkh-ecdsa-secp256k1 script.
This part of a series of commits to fully implement the stdscript
package.
This adds an example for determining the script type of a public key
script in terms of standardness.
This part of a series of commits to fully implement the stdscript
package.
BenchmarkExtractAtomicSwapDataPushes
------------------------------------
v0_complex_not_atomic_swap 15944958 76.34 ns/op 0 B/op 0 allocs/op
v0_normal_valid_atomic_swap 3660967 335.9 ns/op 96 B/op 1 allocs/op
This part of a series of commits to fully implement the stdscript
package.
This adds support for identifying if a redeem script is a version 0
atomic swap redeem script for an original pay-to-script-hash script as a
convenience method for consumers of the package.
Note that this is different than most other methods in the package in
that it applies to the redeem script as opposed to the public key script
and consequently there is no new script type introduced nor does the
overall script determination detect it. This is the case because a
redeem script is the final push of a signature script that is itself a
redemption of a pay-to-script-hash script.
Full test coverage is included.
This is part of a series of commits to fully implement the stdscript
package.
This adds a convenience method to create a standard version 0 ecdsa
multisignature redemption script that requires a threshold of signatures
from a set of public keys.
Full test coverage is included.
This is part of a series of commits to fully implement the stdscript
package.
BenchmarkIsTreasuryGenScriptHashScript
--------------------------------------
v0_complex_non_standard 814816624 1.310 ns/op 0 allocs/op
v0_treasury_generation_p2sh 520297904 2.274 ns/op 0 allocs/op
This is part of a series of commits to fully implement the stdscript
package.
This adds support for detecting version 0 treasury generation
pay-to-script-hash scripts as standard and extracting the associated
script hash.
Full test coverage is included.
This is part of a series of commits to fully implement the stdscript
package.
BenchmarkIsTreasuryGenPubKeyHashScript
--------------------------------------
v0_complex_non_standard 317927872 3.843 ns/op 0 allocs/op
v0_treasury_gen_p2pkh-ecdsa-secp256k1 225968358 5.261 ns/op 0 allocs/op
This is part of a series of commits to fully implement the stdscript
package.
This adds support for detecting version 0 treasury generation
pay-to-pubkey-hash scripts as standard and extracting the associated
public key hash.
Full test coverage is included.
This is part of a series of commits to fully implement the stdscript
package.
BenchmarkIsTreasuryAddScript
----------------------------
v0_complex_non_standard 905938653 1.328 ns/op 0 allocs/op
v0_treasury_add 1000000000 0.9594 ns/op 0 allocs/op
This is part of a series of commits to fully implement the stdscript
package.
This adds support for detecting version 0 treasury add scripts as
standard.
Full test coverage is included.
This is part of a series of commits to fully implement the stdscript
package.
BenchmarkIsStakeChangeScriptHash
--------------------------------
v0_complex_non_standard 688796947 1.626 ns/op 0 allocs/op
v0_stake_change_p2sh 503956689 2.282 ns/op 0 allocs/op
This is part of a series of commits to fully implement the stdscript
package.
This adds support for detecting version 0 stake change
pay-to-script-hash scripts as standard and extracting the associated
script hash.
Full test coverage is included.
This is part of a series of commits to fully implement the stdscript
package.
BenchmarkIsStakeChangePubKeyHash
--------------------------------
v0_complex_non_standard 311063840 3.794 ns/op 0 allocs/op
v0_stake_change_p2pkh-ecdsa-secp256k1 228116065 5.355 ns/op 0 allocs/op
This is part of a series of commits to fully implement the stdscript
package.
This adds support for detecting version 0 stake change
pay-to-pubkey-hash scripts as standard and extracting the associated
public key hash.
Full test coverage is included.
This is part of a series of commits to fully implement the stdscript
package.
BenchmarkIsStakeRevocationScriptHashScript
------------------------------------------
v0_complex_non_standard 725635868 1.631 ns/op 0 allocs/op
v0_stake_revoke_p2sh 522431919 2.571 ns/op 0 allocs/op
This is part of a series of commits to fully implement the stdscript
package.
This adds support for detecting version 0 stake revocation
pay-to-script-hash scripts as standard and extracting the associated
script hash.
Full test coverage is included.
This is part of a series of commits to fully implement the stdscript
package.
BenchmarkIsStakeRevocationPubKeyHashScript
------------------------------------------
v0_complex_non_standard 311770504 3.842 ns/op 0 allocs/op
v0_stake_revoke_p2pkh-ecdsa-secp256k1 228088618 5.316 ns/op 0 allocs/op
This is part of a series of commits to fully implement the stdscript
package.
This adds support for detecting version 0 stake revocation
pay-to-pubkey-hash scripts as standard and extracting the associated
public key hash.
Full test coverage is included.
This is part of a series of commits to fully implement the stdscript
package.
BenchmarkIsStakeGenScriptHashScript
-----------------------------------
v0_complex_non_standard 748967828 1.612 ns/op 0 allocs/op
v0_stake_gen_p2sh 536599674 2.234 ns/op 0 allocs/op
This is part of a series of commits to fully implement the stdscript
package.