@@ -205,7 +205,7 @@ data XPubKey = XPubKey
205205 -- ^ derivation index
206206 , xPubChain :: ! ChainCode
207207 -- ^ chain code
208- , xPubKey :: ! PubKey
208+ , xPubKey :: ! PubKeyXY
209209 -- ^ public key of this node
210210 }
211211 deriving (Generic , Eq , Show , Read , NFData , Hashable )
@@ -244,7 +244,7 @@ makeXPrvKey bs =
244244 XPrvKey 0 (Fingerprint 0 ) 0 c k
245245 where
246246 (p, c) = split512 $ hmac512 " Bitcoin seed" bs
247- k = fromMaybe err (secKey (runPutS (serialize p)))
247+ k = fromMaybe err (importSecKey (runPutS (serialize p)))
248248 err = throw $ DerivationException " Invalid seed"
249249
250250
@@ -277,7 +277,7 @@ prvSubKey xkey child
277277 | otherwise = error " Invalid child derivation index"
278278 where
279279 pK = xPubKey $ deriveXPubKey xkey
280- m = B. append (exportPubKey True pK) (runPutS (serialize child))
280+ m = B. append (exportPubKeyXY True pK) (runPutS (serialize child))
281281 (a, c) = split512 $ hmac512 (runPutS $ serialize $ xPrvChain xkey) m
282282 k = fromMaybe err $ tweakSecKey (xPrvKey xkey) a
283283 err = throw $ DerivationException " Invalid prvSubKey derivation"
@@ -297,7 +297,7 @@ pubSubKey xKey child
297297 XPubKey (xPubDepth xKey + 1 ) (xPubFP xKey) child c pK
298298 | otherwise = error " Invalid child derivation index"
299299 where
300- m = B. append (exportPubKey True (xPubKey xKey)) (runPutS $ serialize child)
300+ m = B. append (exportPubKeyXY True (xPubKey xKey)) (runPutS $ serialize child)
301301 (a, c) = split512 $ hmac512 (runPutS $ serialize $ xPubChain xKey) m
302302 pK = fromMaybe err $ tweakPubKey (xPubKey xKey) a
303303 err = throw $ DerivationException " Invalid pubSubKey derivation"
@@ -359,7 +359,7 @@ xPrvID = xPubID . deriveXPubKey
359359
360360-- | Computes the key identifier of an extended public key.
361361xPubID :: XPubKey -> Hash160
362- xPubID = ripemd160 . runPutS . serialize . sha256 . exportPubKey True . xPubKey
362+ xPubID = ripemd160 . runPutS . serialize . sha256 . exportPubKeyXY True . xPubKey
363363
364364
365365-- | Computes the key fingerprint of an extended private key.
@@ -477,15 +477,15 @@ hardSubKeys k = map (\i -> (hardSubKey k i, i)) . cycleIndex
477477
478478
479479-- | Derive a standard address from an extended public key and an index.
480- deriveAddr :: XPubKey -> KeyIndex -> (Address , PubKey )
480+ deriveAddr :: XPubKey -> KeyIndex -> (Address , PubKeyXY )
481481deriveAddr k i =
482482 (xPubAddr key, xPubKey key)
483483 where
484484 key = pubSubKey k i
485485
486486
487487-- | Derive a SegWit P2WPKH address from an extended public key and an index.
488- deriveWitnessAddr :: XPubKey -> KeyIndex -> (Address , PubKey )
488+ deriveWitnessAddr :: XPubKey -> KeyIndex -> (Address , PubKeyXY )
489489deriveWitnessAddr k i =
490490 (xPubWitnessAddr key, xPubKey key)
491491 where
@@ -494,7 +494,7 @@ deriveWitnessAddr k i =
494494
495495-- | Derive a backwards-compatible SegWit P2SH-P2WPKH address from an extended
496496-- public key and an index.
497- deriveCompatWitnessAddr :: XPubKey -> KeyIndex -> (Address , PubKey )
497+ deriveCompatWitnessAddr :: XPubKey -> KeyIndex -> (Address , PubKeyXY )
498498deriveCompatWitnessAddr k i =
499499 (xPubCompatWitnessAddr key, xPubKey key)
500500 where
@@ -503,7 +503,7 @@ deriveCompatWitnessAddr k i =
503503
504504-- | Cyclic list of all addresses derived from a public key starting from an
505505-- offset index.
506- deriveAddrs :: XPubKey -> KeyIndex -> [(Address , PubKey , KeyIndex )]
506+ deriveAddrs :: XPubKey -> KeyIndex -> [(Address , PubKeyXY , KeyIndex )]
507507deriveAddrs k =
508508 map f . cycleIndex
509509 where
@@ -512,7 +512,7 @@ deriveAddrs k =
512512
513513-- | Cyclic list of all SegWit P2WPKH addresses derived from a public key
514514-- starting from an offset index.
515- deriveWitnessAddrs :: XPubKey -> KeyIndex -> [(Address , PubKey , KeyIndex )]
515+ deriveWitnessAddrs :: XPubKey -> KeyIndex -> [(Address , PubKeyXY , KeyIndex )]
516516deriveWitnessAddrs k =
517517 map f . cycleIndex
518518 where
@@ -521,7 +521,7 @@ deriveWitnessAddrs k =
521521
522522-- | Cyclic list of all backwards-compatible SegWit P2SH-P2WPKH addresses
523523-- derived from a public key starting from an offset index.
524- deriveCompatWitnessAddrs :: XPubKey -> KeyIndex -> [(Address , PubKey , KeyIndex )]
524+ deriveCompatWitnessAddrs :: XPubKey -> KeyIndex -> [(Address , PubKeyXY , KeyIndex )]
525525deriveCompatWitnessAddrs k =
526526 map f . cycleIndex
527527 where
@@ -1026,14 +1026,14 @@ applyPath path key =
10261026{- Helpers for derivation paths and addresses -}
10271027
10281028-- | Derive an address from a given parent path.
1029- derivePathAddr :: XPubKey -> SoftPath -> KeyIndex -> (Address , PubKey )
1029+ derivePathAddr :: XPubKey -> SoftPath -> KeyIndex -> (Address , PubKeyXY )
10301030derivePathAddr key path = deriveAddr (derivePubPath path key)
10311031
10321032
10331033-- | Cyclic list of all addresses derived from a given parent path and starting
10341034-- from the given offset index.
10351035derivePathAddrs ::
1036- XPubKey -> SoftPath -> KeyIndex -> [(Address , PubKey , KeyIndex )]
1036+ XPubKey -> SoftPath -> KeyIndex -> [(Address , PubKeyXY , KeyIndex )]
10371037derivePathAddrs key path = deriveAddrs (derivePubPath path key)
10381038
10391039
0 commit comments