Skip to content

Commit

Permalink
[cgo] refs skycoin#105 Added type error
Browse files Browse the repository at this point in the history
	SKY_ErrSerializedKeyWrongSize
	SKY_ErrHardenedChildPublicKey
	SKY_bip32_ErrInvalidChecksum
	SKY_ErrDerivedInvalidPrivateKey
	SKY_ErrDerivedInvalidPublicKey
	SKY_ErrInvalidPrivateKeyVersion
	SKY_ErrInvalidPublicKeyVersion
	SKY_ErrInvalidSeedLength
	SKY_ErrDeserializePrivateFromPublic
	SKY_ErrInvalidKeyVersion
	SKY_ErrInvalidFingerprint
	SKY_ErrInvalidChildNumber
	SKY_ErrInvalidPrivateKey
	SKY_ErrInvalidPublicKey
	SKY_ErrMaxDepthReached
  • Loading branch information
Maykel Arias Torres committed Aug 18, 2019
1 parent 1a0f180 commit 465b9d8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 29 deletions.
16 changes: 16 additions & 0 deletions include/skyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@
#define SKY_ErrInvalidPassword 0x02000032
#define SKY_ErrReadDataLengthFailed 0x02000033
#define SKY_ErrInvalidDataLength 0x02000034
#define SKY_ErrSerializedKeyWrongSize 0x02000035
#define SKY_ErrHardenedChildPublicKey 0x02000036
#define SKY_bip32_ErrInvalidChecksum 0x02000037
#define SKY_ErrDerivedInvalidPrivateKey 0x02000038
#define SKY_ErrDerivedInvalidPublicKey 0x02000039
#define SKY_ErrInvalidPrivateKeyVersion 0x0200003A
#define SKY_ErrInvalidPublicKeyVersion 0x0200003B
#define SKY_ErrInvalidSeedLength 0x0200003C
#define SKY_ErrDeserializePrivateFromPublic 0x0200003D
#define SKY_ErrInvalidKeyVersion 0x0200003E
#define SKY_ErrInvalidFingerprint 0x0200003F
#define SKY_ErrInvalidChildNumber 0x02000040
#define SKY_ErrInvalidPrivateKey 0x02000041
#define SKY_ErrInvalidPublicKey 0x02000042
#define SKY_ErrMaxDepthReached 0x02000043

// cli error codes
#define SKY_ErrTemporaryInsufficientBalance 0x03000000
Expand Down Expand Up @@ -213,6 +228,7 @@
#define SKY_ErrVerifySignatureInvalidSigLength 0x0B000034
#define SKY_ErrVerifySignatureInvalidPubkeysLength 0x0B000035


// daemon error codes
#define SKY_ErrInvalidDecimals 0x0C000000

Expand Down
34 changes: 34 additions & 0 deletions lib/cgo/libsky_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/skycoin/skycoin/src/transaction"

"github.com/skycoin/skycoin/src/cipher"
"github.com/skycoin/skycoin/src/cipher/bip32"
"github.com/skycoin/skycoin/src/cipher/encoder"
"github.com/skycoin/skycoin/src/cipher/encrypt"
"github.com/skycoin/skycoin/src/cli"
Expand Down Expand Up @@ -179,6 +180,23 @@ const (
SKY_ErrReadDataLengthFailed
// SKY_ErrInvalidDataLength invalid data length
SKY_ErrInvalidDataLength

// bip32
SKY_ErrSerializedKeyWrongSize
SKY_ErrHardenedChildPublicKey
SKY_bip32_ErrInvalidChecksum
SKY_ErrDerivedInvalidPrivateKey
SKY_ErrDerivedInvalidPublicKey
SKY_ErrInvalidPrivateKeyVersion
SKY_ErrInvalidPublicKeyVersion
SKY_ErrInvalidSeedLength
SKY_ErrDeserializePrivateFromPublic
SKY_ErrInvalidKeyVersion
SKY_ErrInvalidFingerprint
SKY_ErrInvalidChildNumber
SKY_ErrInvalidPrivateKey
SKY_ErrInvalidPublicKey
SKY_ErrMaxDepthReached
)

// Error codes defined in cli package
Expand Down Expand Up @@ -591,6 +609,22 @@ var (
visor.ErrDuplicateUxOuts: SKY_ErrDuplicateUxOuts,
// params
params.ErrInvalidDecimals: SKY_ErrInvalidDecimals,
// bip32
bip32.ErrSerializedKeyWrongSize: SKY_ErrSerializedKeyWrongSize,
bip32.ErrHardenedChildPublicKey: SKY_ErrHardenedChildPublicKey,
bip32.ErrInvalidChecksum: SKY_bip32_ErrInvalidChecksum,
bip32.ErrDerivedInvalidPrivateKey: SKY_ErrDerivedInvalidPrivateKey,
bip32.ErrDerivedInvalidPublicKey: SKY_ErrDerivedInvalidPublicKey,
bip32.ErrInvalidPrivateKeyVersion: SKY_ErrInvalidPrivateKeyVersion,
bip32.ErrInvalidPublicKeyVersion: SKY_ErrInvalidPublicKeyVersion,
bip32.ErrInvalidSeedLength: SKY_ErrInvalidSeedLength,
bip32.ErrDeserializePrivateFromPublic: SKY_ErrDeserializePrivateFromPublic,
bip32.ErrInvalidKeyVersion: SKY_ErrInvalidKeyVersion,
bip32.ErrInvalidFingerprint: SKY_ErrInvalidFingerprint,
bip32.ErrInvalidChildNumber: SKY_ErrInvalidChildNumber,
bip32.ErrInvalidPrivateKey: SKY_ErrInvalidPrivateKey,
bip32.ErrInvalidPublicKey: SKY_ErrInvalidPublicKey,
bip32.ErrMaxDepthReached: SKY_ErrMaxDepthReached,
}
)

Expand Down
30 changes: 1 addition & 29 deletions lib/cgo/tests/check_cipher.bip32.bip32.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,6 @@
#include "skytest.h"
#include <check.h>

typedef struct {
GoString path;
GoString privKey;
GoString pubKey;
GoString fingerprint;
GoString identifier;
GoString chainCode;
GoString hexPubKey;
GoString wifPrivKey;
GoUint32 childNumber;
GoUint8 depth;
} testChildKey;

typedef struct {
GoString seed;
testChildKey children[12];
GoString privKey;
GoString pubKey;
GoString hexPubKey;
GoString wifPrivKey;
GoString fingerprint;
GoString identifier;
GoString chainCode;
GoUint32 childNumber;
GoUint8 depth;
} testMasterKey;


START_TEST(TestMaxChildDepthError)
{
GoUint8 bufferTemp[1024];
Expand All @@ -48,7 +20,7 @@ START_TEST(TestMaxChildDepthError)
err = SKY_bip32_Private_NewPrivateChildKey(key, 0, &key);
switch (i) {
case 255:
ck_assert_int_eq(err, SKY_ERROR);
ck_assert_int_eq(err, SKY_ErrMaxDepthReached);
reached = 1;
break;

Expand Down

0 comments on commit 465b9d8

Please sign in to comment.