pkt-cash / pktd

The PKT full node and wallet
https://pkt.cash/
ISC License
39 stars 27 forks source link

'verifymessage' fails for messages signed using segwit address #381

Open 3rror404 opened 1 year ago

3rror404 commented 1 year ago

Messages can be signed successfully with both legacy and segwit addresses using the signmessage command, but messages signed with segwit addresses can not be verified with the verifymessage command.

The messages seem to be signed correctly, as can be verified here: https://www.verifybitcoinmessage.com/

Examples

Legacy address

Address: p5iG9HLZoVCMNYCYyYHj4aPBJ6rwiHhg7n Message: Hello, world! Signature: H0drZIYwca61ZKCXJ0uEWNgwztgTwbX9Te70K18t8XVeFS8hcNO4fRxi7zpbgR9tbemYF0etnX3ybhqAJfUUTZ8=

Segwit address

Address: pkt1q6sj0mchq7ltwm8c9tpm2wteqmeldr2ye5lcr60 Message: Hello, world! Signature: IH73zLeFgqeYZL0zSnS0bMbumiwYaiY7521KqrG4rjDKENMhPGJljlTAM86EPqeI4+CnXn7xoHXSMim/OsBPLUo=

Error

{
    "code": -32603,
    "message": "1.6.1 address type not supported",
    "stack": [
        "  btcutil/er/er.go:359 +0x28\t  btcutil/er.New({0x10520ccee, 0x1a})",
        "  pktwallet/rpc/legacyrpc/methods.go:1830 +0x268\t  pktwallet/rpc/legacyrpc.verifyMessage({0x1055a7500?, 0x14001558540}, 0x105708ea0?)",
        "  pktwallet/rpc/legacyrpc/methods.go:174 +0x30\t  pktwallet/rpc/legacyrpc.lazyApplyHandler.func5({0x1055a7500?, 0x14001558540?})",
        "  pktwallet/rpc/legacyrpc/methods.go:154 +0x60\t  pktwallet/rpc/legacyrpc.lazyApplyHandler.lazyApplyHandler.func1.func10()",
        "  pktwallet/rpc/legacyrpc/server.go:602 +0x1cc\t  pktwallet/rpc/legacyrpc.(*Server).postClientRPC(0x14000276780, {0x1057030b0?, 0x140005dcd20}, 0xc?)",
        "  pktwallet/rpc/legacyrpc/server.go:138 +0x268\t  pktwallet/rpc/legacyrpc.NewServer.func2({0x1057030b0, 0x140005dcd20}, 0x14011a25500)",
        "  net/http/server.go:2136 +0x38\t  net/http.HandlerFunc.ServeHTTP(0x14011090a68?, {0x1057030b0?, 0x140005dcd20?}, 0x104bb65dc?)",
        "  pktwallet/rpc/legacyrpc/server.go:342 +0x128\t  pktwallet/rpc/legacyrpc.NewServer.throttledFn.throttled.func4({0x1057030b0?, 0x140005dcd20?}, 0x14011090b08?)",
        "  net/http/server.go:2136 +0x38\t  net/http.HandlerFunc.ServeHTTP(0x14010a7c56c?, {0x1057030b0?, 0x140005dcd20?}, 0x14011090af0?)",
        "  net/http/server.go:2514 +0x144\t  net/http.(*ServeMux).ServeHTTP(0x10?, {0x1057030b0, 0x140005dcd20}, 0x14011a25500)",
        "  net/http/server.go:2938 +0xbc\t  net/http.serverHandler.ServeHTTP({0x105700a48?}, {0x1057030b0?, 0x140005dcd20?}, 0x6?)",
        "  net/http/server.go:2009 +0x518\t  net/http.(*conn).serve(0x1400022fd40, {0x105704538, 0x1400021f2c0})",
        "  net/http/server.go:3086 +0x4cc\t  created by net/http.(*Server).Serve in goroutine 55"
    ]
}