anchor: change is not an arbitrary output, but a pubkey we p2sh to.

Gets rid of the last pubkey user; they're generally deprecated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2015-06-05 12:24:58 +09:30
parent 29d0cdc3cd
commit d30c470c7d
7 changed files with 183 additions and 162 deletions

View File

@@ -1,5 +1,6 @@
#include "pubkey.h"
#include <openssl/ecdsa.h>
#include <ccan/str/hex/hex.h>
/* Must agree on key validity with bitcoin! Stolen from bitcoin/src/pubkey.h's
* GetLen:
@@ -52,3 +53,15 @@ bool proto_to_pubkey(const BitcoinPubkey *pb, struct pubkey *key)
memcpy(key->key, pb->key.data, pb->key.len);
return true;
}
bool pubkey_from_hexstr(const char *str, struct pubkey *key)
{
size_t slen = strlen(str), dlen;
dlen = hex_data_size(slen);
if (dlen != 33 && dlen != 65)
return false;
if (!hex_decode(str, slen, key->key, dlen))
return false;
return GetLen(key->key[0]) == dlen;
}