Giter Club home page Giter Club logo

Comments (3)

dgpv avatar dgpv commented on August 16, 2024

Yes, it looks like we should just return None if utxo is not set, now it always raises an exception

utxo = self.witness_utxo or self.utxo
if utxo is None:
raise ValueError(
f'utxo is not set for of PSBT_Input at index {self.index}')

a few lines above there's also a check if the index is set on UTXO:

if self.index is None:
raise ValueError(
'index is not set for PSBT_Input')

index on the input may be unset if someone created PSBT_Input directly and did not supply or did not set the index.

It seems to me that conceptually, in both of this cases we can just return "None" and not throw execption.

The only situation where throwing an exception seems to be of value is when someone needs to make sure that all inputs are signable. But "unsignable" inputs return None in other cases such as unrecognized script, and the check can be accomplished just by iterating over psbt.inputs doing if inp.sign(...) is None:

I think I will just replace raise ValueError(...) with return None in both cases: #53

Let me know if you think that there's a better way to handle this

from python-bitcointx.

AdamISZ avatar AdamISZ commented on August 16, 2024

From my view, I think returning None is right. A caller can always inspect the SignResult object to check (I think?) that the result is as intended. I believe I agree also about index; I don't have such a use case right now, but I could maybe imagine it.

from python-bitcointx.

dgpv avatar dgpv commented on August 16, 2024

I released v1.1.1.post2 with the fix

from python-bitcointx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.