Skip to content

Commit df9da3a

Browse files
vostrnadluke-jr
authored andcommitted
Add a -permitbarepubkey option
Github-Pull: bitcoin#29309 Rebased-From: 8c1114a
1 parent 8a59be4 commit df9da3a

File tree

6 files changed

+12
-2
lines changed

6 files changed

+12
-2
lines changed

src/init.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@ void SetupServerArgs(ArgsManager& argsman)
651651
argsman.AddArg("-mempoolfullrbf", strprintf("Accept transaction replace-by-fee without requiring replaceability signaling (default: %u)", (DEFAULT_MEMPOOL_RBF_POLICY == RBFPolicy::Always)), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
652652
argsman.AddArg("-mempoolreplacement", strprintf("Set to 0 to disable RBF entirely, \"fee,optin\" to honour RBF opt-out signal, or \"fee,-optin\" to always RBF aka full RBF (default: %s)", "fee,-optin"), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
653653
argsman.AddArg("-mempooltruc", strprintf("Behaviour for transactions requesting TRUC limits: \"reject\" the transactions entirely, \"accept\" them just like any other, or \"enforce\" to impose their requested restrictions (default: %s)", "enforce"), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
654+
argsman.AddArg("-permitbarepubkey", strprintf("Relay legacy pubkey outputs (default: %u)", DEFAULT_PERMIT_BAREPUBKEY), ArgsManager::ALLOW_ANY,
655+
OptionsCategory::NODE_RELAY);
654656
argsman.AddArg("-permitbaremultisig", strprintf("Relay transactions creating non-P2SH multisig outputs (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,
655657
OptionsCategory::NODE_RELAY);
656658
argsman.AddArg("-minrelaytxfee=<amt>", strprintf("Fees (in %s/kvB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)",

src/kernel/mempool_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct MemPoolOptions {
5858
* If nullopt, any size is nonstandard.
5959
*/
6060
std::optional<unsigned> max_datacarrier_bytes{DEFAULT_ACCEPT_DATACARRIER ? std::optional{MAX_OP_RETURN_RELAY} : std::nullopt};
61+
bool permit_bare_pubkey{DEFAULT_PERMIT_BAREPUBKEY};
6162
bool permit_bare_multisig{DEFAULT_PERMIT_BAREMULTISIG};
6263
bool require_standard{true};
6364
RBFPolicy rbf_policy{DEFAULT_MEMPOOL_RBF_POLICY};

src/node/mempool_args.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& argsman, const CChainP
8181
}
8282
}
8383

84+
mempool_opts.permit_bare_pubkey = argsman.GetBoolArg("-permitbarepubkey", DEFAULT_PERMIT_BAREPUBKEY);
85+
8486
mempool_opts.permit_bare_multisig = argsman.GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG);
8587

8688
if (argsman.GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER)) {

src/policy/policy.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ bool IsStandardTx(const CTransaction& tx, const kernel::MemPoolOptions& opts, st
161161
nDataOut++;
162162
continue;
163163
}
164+
else if ((whichType == TxoutType::PUBKEY) && (!opts.permit_bare_pubkey)) {
165+
MaybeReject("bare-pubkey");
166+
}
164167
else if ((whichType == TxoutType::MULTISIG) && (!opts.permit_bare_multisig)) {
165168
MaybeReject("bare-multisig");
166169
}

src/policy/policy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/
3939
static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{1000};
4040
/** Default for -bytespersigop */
4141
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20};
42+
/** Default for -permitbarepubkey */
43+
static constexpr bool DEFAULT_PERMIT_BAREPUBKEY{true};
4244
/** Default for -permitbaremultisig */
4345
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true};
4446
/** The maximum number of witness stack items in a standard P2WSH script */

src/test/fuzz/transaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ FUZZ_TARGET(transaction, .init = initialize_transaction)
5959
}
6060

6161
std::string reason;
62-
const bool is_standard_with_permit_bare_multisig = IsStandardTx(tx, kernel::MemPoolOptions{.permit_bare_multisig = true}, reason);
63-
const bool is_standard_without_permit_bare_multisig = IsStandardTx(tx, kernel::MemPoolOptions{.permit_bare_multisig = false}, reason);
62+
const bool is_standard_with_permit_bare_multisig = IsStandardTx(tx, kernel::MemPoolOptions{.permit_bare_pubkey = true, .permit_bare_multisig = true}, reason);
63+
const bool is_standard_without_permit_bare_multisig = IsStandardTx(tx, kernel::MemPoolOptions{.permit_bare_pubkey = true, .permit_bare_multisig = false}, reason);
6464
if (is_standard_without_permit_bare_multisig) {
6565
assert(is_standard_with_permit_bare_multisig);
6666
}

0 commit comments

Comments
 (0)