Explicit calculation which is used to test the wallet constant We get the same virtual size due to rounding(weight/4) for both use_max_sig values
| 531 | // Explicit calculation which is used to test the wallet constant |
| 532 | // We get the same virtual size due to rounding(weight/4) for both use_max_sig values |
| 533 | static size_t CalculateNestedKeyhashInputSize(bool use_max_sig) |
| 534 | { |
| 535 | // Generate ephemeral valid pubkey |
| 536 | CKey key = GenerateRandomKey(); |
| 537 | CPubKey pubkey = key.GetPubKey(); |
| 538 | |
| 539 | // Generate pubkey hash |
| 540 | uint160 key_hash(Hash160(pubkey)); |
| 541 | |
| 542 | // Create inner-script to enter into keystore. Key hash can't be 0... |
| 543 | CScript inner_script = CScript() << OP_0 << std::vector<unsigned char>(key_hash.begin(), key_hash.end()); |
| 544 | |
| 545 | // Create outer P2SH script for the output |
| 546 | uint160 script_id(Hash160(inner_script)); |
| 547 | CScript script_pubkey = CScript() << OP_HASH160 << std::vector<unsigned char>(script_id.begin(), script_id.end()) << OP_EQUAL; |
| 548 | |
| 549 | // Add inner-script to key store and key to watchonly |
| 550 | FillableSigningProvider keystore; |
| 551 | keystore.AddCScript(inner_script); |
| 552 | keystore.AddKeyPubKey(key, pubkey); |
| 553 | |
| 554 | // Fill in dummy signatures for fee calculation. |
| 555 | SignatureData sig_data; |
| 556 | |
| 557 | if (!ProduceSignature(keystore, use_max_sig ? DUMMY_MAXIMUM_SIGNATURE_CREATOR : DUMMY_SIGNATURE_CREATOR, script_pubkey, sig_data)) { |
| 558 | // We're hand-feeding it correct arguments; shouldn't happen |
| 559 | assert(false); |
| 560 | } |
| 561 | |
| 562 | CTxIn tx_in; |
| 563 | UpdateInput(tx_in, sig_data); |
| 564 | return (size_t)GetVirtualTransactionInputSize(tx_in); |
| 565 | } |
| 566 | |
| 567 | BOOST_FIXTURE_TEST_CASE(dummy_input_size_test, TestChain100Setup) |
| 568 | { |
no test coverage detected