bitcoin/src/script
Andrew Chow 888628cee0
Merge bitcoin/bitcoin#25827: descriptor: check if rawtr has only one key.
416ceb8661 descriptor: check if `rawtr` has only one key. (w0xlt)

Pull request description:

  If I understand `rawtr` descriptor correctly, it should only allow `rawtr(KEY)`, not `rawtr(KEY1, KEY2, ...)` or other concatenations.

  On master branch, `rawtr(KEY1, KEY2, ...)` will produce the `rawtr(KEY1)` descriptor ignoring the `KEY2, ...` with no error messages or warnings.

  For example, the code below will print `rawtr(tprv8ZgxMBicQKsPefef2Doobbq3xTCaVTHcDn6me82KSXY1vY9AJAWD5u7SDM4XGLfc4EoXRMFrJKpp6HNmQWA3FTMRQeEmMJYJ9RPqe9ne2hU/*)#lx9qryfh`
  for the supposedly invalid descriptor
  `rawtr(tprv8ZgxMBicQKsPefef2Doobbq3xTCaVTHcDn6me82KSXY1vY9AJAWD5u7SDM4XGLfc4EoXRMFrJKpp6HNmQWA3FTMRQeEmMJYJ9RPqe9ne2hU/*, tprv8ZgxMBicQKsPezQ2KGArMRovTEbCGxaLgBgaVcTvEx8mby8ogX2bgC4HBapH4yMwrz2FpoCuA17eocuUVMgEP6fnm83YpwSDTFrumw42bny/*)`
  ```python
          self.nodes[1].createwallet(wallet_name="rawtr_multi", descriptors=True, blank=True)
          rawtr_multi = self.nodes[1].get_wallet_rpc("rawtr_multi")
          rawtr_multi_desc = "rawtr(tprv8ZgxMBicQKsPefef2Doobbq3xTCaVTHcDn6me82KSXY1vY9AJAWD5u7SDM4XGLfc4EoXRMFrJKpp6HNmQWA3FTMRQeEmMJYJ9RPqe9ne2hU/*, tprv8ZgxMBicQKsPezQ2KGArMRovTEbCGxaLgBgaVcTvEx8mby8ogX2bgC4HBapH4yMwrz2FpoCuA17eocuUVMgEP6fnm83YpwSDTFrumw42bny/*)#uv78hkt0"
          result = rawtr_multi.importdescriptors([{"desc": rawtr_multi_desc, "active": True, "timestamp": "now"}])

          print(rawtr_multi.listdescriptors(True))
  ```

  This PR adds a check that prevents `rawtr` descriptors from being created if more than one key is entered, shows an error message, and adds a test for this case.

ACKs for top commit:
  achow101:
    ACK 416ceb8661
  sipa:
    ACK 416ceb8661

Tree-SHA512: a2009e91f1bca6ee79cc68f65811caa6a21fc8b80acd8dc58e283f424b41fe53b0db7ce3693b1c7e2184ff571e6d1fbb9f5ccde89b65d3026726f3393c492044
2022-08-18 16:50:43 -04:00
..
bitcoinconsensus.cpp Use spans of std::byte in serialize 2022-01-02 11:40:31 +01:00
bitcoinconsensus.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
descriptor.cpp Merge bitcoin/bitcoin#25827: descriptor: check if rawtr has only one key. 2022-08-18 16:50:43 -04:00
descriptor.h scripted-diff: Bump copyright headers 2021-12-30 19:36:57 +02:00
interpreter.cpp Use HashWriter where possible 2022-07-20 15:34:36 +02:00
interpreter.h Use HashWriter where possible 2022-07-20 15:34:36 +02:00
keyorigin.h Implement operator< for KeyOriginInfo and CExtPubKey 2021-12-10 08:29:47 -05:00
miniscript.cpp miniscript: nit: don't return after assert(false) 2022-05-30 15:16:45 +02:00
miniscript.h miniscript: add a helper to find the first insane sub with no child 2022-07-14 12:03:49 +02:00
script.cpp script: move CheckMinimalPush from interpreter to script.h 2022-03-17 14:09:06 +01:00
script.h script: actually trigger the optimization in BuildScript 2022-07-26 13:02:48 +02:00
script_error.cpp Implement Tapscript script validation rules (BIP 342) 2020-10-12 17:18:24 -07:00
script_error.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
sigcache.cpp validationcaches: Use size_t for sizes 2022-08-03 12:03:28 -04:00
sigcache.h validationcaches: Use size_t for sizes 2022-08-03 12:03:28 -04:00
sign.cpp Merge bitcoin/bitcoin#25664: refactor: Redefine IsSolvable() using descriptors 2022-08-11 13:41:47 -04:00
sign.h script/sign: remove needless IsSolvable() utility 2022-08-11 15:43:40 +02:00
signingprovider.cpp refactor: Avoid copies in FlatSigningProvider Merge 2022-08-12 17:19:16 +02:00
signingprovider.h refactor: Avoid copies in FlatSigningProvider Merge 2022-08-12 17:19:16 +02:00
standard.cpp Remove ::g_max_datacarrier_bytes global 2022-08-02 15:29:16 +02:00
standard.h Remove ::g_max_datacarrier_bytes global 2022-08-02 15:29:16 +02:00