Skip to content

Conversation

Sjors
Copy link
Member

@Sjors Sjors commented Feb 28, 2020

A PSBT signed by ColdCard was analyzed as follows (see #17509 (comment))

{
  "inputs": [
    {
      "has_utxo": true,
      "is_final": false,
      "next": "finalizer"
    }
  ],
  "estimated_vsize": 141,
  "estimated_feerate": 1e-05,
  "fee": 1.41e-06,
  "next": "signer"
}

I changed AnalyzePSBT so that it returns "next": "finalizer" instead.

@Sjors Sjors mentioned this pull request Feb 28, 2020
@fanquake fanquake added the PSBT label Feb 28, 2020
@Sjors Sjors changed the title psbt: AnalyzePSBT set next to FINALIZER when all inputs need finalizing psbt: AnalyzePSBT set next to"finalizer" when all inputs need finalizing Feb 28, 2020
@Sjors Sjors mentioned this pull request Feb 28, 2020
@instagibbs
Copy link
Member

Can you explain the code path master is hitting? Mind sharing the PSBT? :)

@Sjors
Copy link
Member Author

Sjors commented Feb 28, 2020

Just try with a ColdCard simulator, it's pretty reproducible. On master result.next is set to SIGNER because only_missing_sigs is checked before only_missing_final. The latter is set to true along with the input being marked as FINALIZER.

The reason master doesn't check only_missing_final first is that it starts as false and can be toggled to true for any input. So I reversed that to starting true and being toggled to false if any input is not final.

@instagibbs
Copy link
Member

If it's really easy to set up I think a checked in test is in order

…zing

Previously the next step would be SIGNER if all of the inputs had FINALIZER as their next step.
@Sjors Sjors force-pushed the 2020/02/analyze_psbt branch from a4cdad9 to 64a44dc Compare February 28, 2020 15:57
@Sjors
Copy link
Member Author

Sjors commented Feb 28, 2020

I added a test.

@instagibbs
Copy link
Member

I had such trouble understanding the function I decided a proper refactor of logic was in order: #18224

@Sjors Sjors closed this Feb 28, 2020
meshcollider added a commit that referenced this pull request Mar 2, 2020
1ef28b4 Make AnalyzePSBT next role calculation simple, correct (Gregory Sanders)

Pull request description:

  Sniped test and alternative to #18220

  Sjors documenting the issue:
  ```
  A PSBT signed by ColdCard was analyzed as follows (see #17509 (comment))

  {
    "inputs": [
      {
        "has_utxo": true,
        "is_final": false,
        "next": "finalizer"
      }
    ],
    "estimated_vsize": 141,
    "estimated_feerate": 1e-05,
    "fee": 1.41e-06,
    "next": "signer"
  }
  I changed AnalyzePSBT so that it returns "next": "finalizer" instead.
  ```

  It makes it much clearer that the role has been decided before hitting the `calc_fee` block, and groups all state-deciding in one spot instead of 2.

  Note that this assumes that PSBT roles are a complete ordering, which for now and in the future seems to be a correct assumption.

ACKs for top commit:
  Sjors:
    ACK 1ef28b4, much nicer. Don't forget to document the bug fix.
  achow101:
    ACK 1ef28b4
  Empact:
    ACK 1ef28b4

Tree-SHA512: 22ba4234985c6f9c1445b14565c71268cfaa121c4ef000ee3d5117212b09442dee8d46d9701bceddaf355263fe25dfe40def2ef614d4f2fe66c9ce876cb49934
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 2, 2020
…orrect

1ef28b4 Make AnalyzePSBT next role calculation simple, correct (Gregory Sanders)

Pull request description:

  Sniped test and alternative to bitcoin#18220

  Sjors documenting the issue:
  ```
  A PSBT signed by ColdCard was analyzed as follows (see bitcoin#17509 (comment))

  {
    "inputs": [
      {
        "has_utxo": true,
        "is_final": false,
        "next": "finalizer"
      }
    ],
    "estimated_vsize": 141,
    "estimated_feerate": 1e-05,
    "fee": 1.41e-06,
    "next": "signer"
  }
  I changed AnalyzePSBT so that it returns "next": "finalizer" instead.
  ```

  It makes it much clearer that the role has been decided before hitting the `calc_fee` block, and groups all state-deciding in one spot instead of 2.

  Note that this assumes that PSBT roles are a complete ordering, which for now and in the future seems to be a correct assumption.

ACKs for top commit:
  Sjors:
    ACK 1ef28b4, much nicer. Don't forget to document the bug fix.
  achow101:
    ACK 1ef28b4
  Empact:
    ACK bitcoin@1ef28b4

Tree-SHA512: 22ba4234985c6f9c1445b14565c71268cfaa121c4ef000ee3d5117212b09442dee8d46d9701bceddaf355263fe25dfe40def2ef614d4f2fe66c9ce876cb49934
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
…orrect

1ef28b4 Make AnalyzePSBT next role calculation simple, correct (Gregory Sanders)

Pull request description:

  Sniped test and alternative to bitcoin#18220

  Sjors documenting the issue:
  ```
  A PSBT signed by ColdCard was analyzed as follows (see bitcoin#17509 (comment))

  {
    "inputs": [
      {
        "has_utxo": true,
        "is_final": false,
        "next": "finalizer"
      }
    ],
    "estimated_vsize": 141,
    "estimated_feerate": 1e-05,
    "fee": 1.41e-06,
    "next": "signer"
  }
  I changed AnalyzePSBT so that it returns "next": "finalizer" instead.
  ```

  It makes it much clearer that the role has been decided before hitting the `calc_fee` block, and groups all state-deciding in one spot instead of 2.

  Note that this assumes that PSBT roles are a complete ordering, which for now and in the future seems to be a correct assumption.

ACKs for top commit:
  Sjors:
    ACK 1ef28b4, much nicer. Don't forget to document the bug fix.
  achow101:
    ACK 1ef28b4
  Empact:
    ACK bitcoin@1ef28b4

Tree-SHA512: 22ba4234985c6f9c1445b14565c71268cfaa121c4ef000ee3d5117212b09442dee8d46d9701bceddaf355263fe25dfe40def2ef614d4f2fe66c9ce876cb49934
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants