Skip to content

Commit 4311e27

Browse files
authored
Merge pull request #272 from frstrtr/dgb/donation-p2sh-bytes-kat
dgb: pin v36 combined-donation P2SH bytes (bucket-2 standardization guard)
2 parents 71af756 + 5117b65 commit 4311e27

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/impl/dgb/test/share_test.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
#include <gtest/gtest.h>
1313

14+
#include <algorithm>
15+
#include <array>
16+
1417
#include <impl/dgb/config_pool.hpp>
1518
#include <impl/dgb/config_coin.hpp>
1619
#include <impl/dgb/share.hpp>
@@ -79,6 +82,36 @@ TEST(DGB_share_test, OracleDonationScript)
7982
EXPECT_EQ(dgb::PoolConfig::get_donation_script(36).size(), 23u); // v36 combined P2SH
8083
}
8184

85+
// v36 combined-donation P2SH — FULL 23-byte pin (bucket-2 standardization).
86+
// OracleDonationScript above pins only the SIZE of the v36 path; a drift in the
87+
// 20-byte hash160 would slip past it. This locks the exact bytes get_donation_
88+
// script(36) emits: OP_HASH160 PUSH20 <hash160> OP_EQUAL, where the hash160 is
89+
// the canonical FLAG6 unified cross-coin v36 donation (1-of-2 forrestv+c2pool
90+
// dev key). 3-bucket rule: the v36 donation target is BUCKET 2 (v36-native
91+
// shared structure), so this hash is byte-identical across ALL v36 coins — the
92+
// same 8c627262… as src/impl/ltc/config_pool.hpp COMBINED_DONATION_SCRIPT.
93+
// Guards against a coin-local fork of the donation target during the transition.
94+
TEST(DGB_share_test, V36CombinedDonationScriptBytes)
95+
{
96+
// hash160 of the FLAG6 1-of-2 P2MS redeem script (forrestv + c2pool dev).
97+
static constexpr std::array<uint8_t, 23> kExpected = {
98+
0xa9, 0x14, // OP_HASH160 PUSH20
99+
0x8c, 0x62, 0x72, 0x62, 0x1d, 0x89, 0xe8, 0xfa,
100+
0x52, 0x6d, 0xd8, 0x6a, 0xcf, 0xf6, 0x0c, 0x71,
101+
0x36, 0xbe, 0x8e, 0x85,
102+
0x87 // OP_EQUAL
103+
};
104+
105+
const auto got = dgb::PoolConfig::get_donation_script(36);
106+
ASSERT_EQ(got.size(), kExpected.size());
107+
for (size_t i = 0; i < kExpected.size(); ++i)
108+
EXPECT_EQ(got[i], kExpected[i]) << "donation byte " << i << " drifted";
109+
110+
// The raw constant the switch returns must match too (no copy divergence).
111+
EXPECT_TRUE(std::equal(kExpected.begin(), kExpected.end(),
112+
dgb::PoolConfig::COMBINED_DONATION_SCRIPT.begin()));
113+
}
114+
82115
// Address byte versions (D… P2PKH / S… P2SH) — DigiByte mainnet.
83116
TEST(DGB_share_test, AddressVersions)
84117
{

0 commit comments

Comments
 (0)