Skip to content

Instantly share code, notes, and snippets.

@reite
Last active December 18, 2015 10:19
Show Gist options
  • Save reite/5767455 to your computer and use it in GitHub Desktop.
Save reite/5767455 to your computer and use it in GitHub Desktop.
parseAddresses :: Object -> Parser [[String]]
parseAddresses v = v .: "vout" >>= mapM (.: "scriptPubKey") >>= mapM (.: "addresses")
@reite
Copy link
Author

reite commented Jun 12, 2013

Input:

{"vout" : [
        {
            "value" : 4.24329986,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 1eb03b02fa6c8e291f07b6843effbf77c3b50f91 OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9141eb03b02fa6c8e291f07b6843effbf77c3b50f9188ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "13oGPU1dF1pEyYuhhJviMBJM4uPdssszfh"
                ]
            }
        },
        {
            "value" : 23.32108861,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 f5576c35be76f147ccf864fbb7ca77fd1c34e493 OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a914f5576c35be76f147ccf864fbb7ca77fd1c34e49388ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1PNFHEZV9MY3t2dLuhhXJKp7Lcat1XGv2a"
                ]
            }
        }
    ]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment