Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Descriptor features #86

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLibWally/libwally-core
Submodule libwally-core updated 54 files
+12 −0 CHANGES.md
+4 −0 README.md
+6 −0 configure.ac
+30 −7 docs/source/conf.py
+45 −9 include/wally.hpp
+39 −29 include/wally_address.h
+17 −17 include/wally_anti_exfil.h
+102 −30 include/wally_bip32.h
+12 −11 include/wally_bip38.h
+8 −12 include/wally_core.h
+118 −63 include/wally_crypto.h
+21 −16 include/wally_descriptor.h
+63 −63 include/wally_elements.h
+11 −11 include/wally_map.h
+72 −46 include/wally_psbt.h
+4 −4 include/wally_psbt_members.h
+46 −70 include/wally_script.h
+3 −3 include/wally_symmetric.h
+42 −42 include/wally_transaction.h
+137 −23 src/bip32.c
+19 −0 src/ccan/ccan/crypto/sha256/sha256.c
+6 −0 src/ccan/ccan/crypto/sha256/sha256.h
+19 −0 src/ccan/ccan/crypto/sha512/sha512.c
+6 −0 src/ccan/ccan/crypto/sha512/sha512.h
+8 −0 src/ccan_config.h
+3 −0 src/ctest/psbts.h
+303 −314 src/ctest/test_descriptor.c
+4 −0 src/data/psbt.json
+115 −45 src/descriptor.c
+11 −3 src/hmac.c
+13 −13 src/hmac.inl
+77 −13 src/internal.c
+10 −2 src/internal.h
+150 −91 src/psbt.c
+4 −2 src/pyexample/liquid/receive-send.py
+52 −66 src/script.c
+95 −1 src/sign.c
+5 −0 src/swig_java/jni_extra.java_in
+4 −1 src/swig_java/swig.i
+3 −5 src/swig_python/python_extra.py_in
+1 −0 src/swig_python/swig.i
+32 −6 src/test/test_bip32.py
+54 −2 src/test/test_descriptor.py
+22 −4 src/test/test_psbt.py
+11 −35 src/test/test_script.py
+44 −7 src/test/test_transaction.py
+15 −7 src/test/util.py
+2 −0 src/transaction.c
+6 −6 src/wasm_package/package-lock.json
+34 −13 src/wasm_package/src/const.js
+8 −4 src/wasm_package/src/functions.js
+8 −2 src/wasm_package/src/index.d.ts
+0 −1 tools/build_wrappers.py
+7 −1 tools/wasm_exports.sh
2 changes: 2 additions & 0 deletions LibWally/Descriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public struct Descriptor {
public var network: Network
public var canonical: String
public var isRanged: Bool
public var miniscript: Bool

// The descriptor is not fully validated.
public init(_ descriptor: String, _ network: Network) throws {
Expand All @@ -37,6 +38,7 @@ public struct Descriptor {
let feature_flags = UnsafeMutablePointer<UInt32>.allocate(capacity: 1)
precondition(wally_descriptor_get_features(wally_descriptor, feature_flags) == WALLY_OK)
self.isRanged = (feature_flags.pointee & UInt32(WALLY_MS_IS_RANGED)) != 0
self.miniscript = (feature_flags.pointee & UInt32(WALLY_MS_IS_DESCRIPTOR)) == 0

// Canonicalize the descriptor
var output: UnsafeMutablePointer<Int8>?
Expand Down
2 changes: 1 addition & 1 deletion LibWally/PSBT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public struct PSBT : Equatable {
defer {
psbt.deallocate()
}
guard wally_psbt_finalize(psbt) == WALLY_OK else {
guard wally_psbt_finalize(psbt, UInt32(0)) == WALLY_OK else {
return false
}
return true
Expand Down
13 changes: 13 additions & 0 deletions LibWallyTests/DescriptorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,17 @@ class DescriptorTests: XCTestCase {
}
}

func testWithoutMiniscript() throws {
let desc = try! Descriptor("pkh([3442193e/0']xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw/1)#62cpuxwx", .mainnet)

XCTAssert(!desc.miniscript)
}

func testWithMiniscript() throws {
let desc = try! Descriptor("wsh(and_v(v:pk([3442193e/0']xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw/1),after(10)))#224tnmsn", .mainnet)

XCTAssert(desc.miniscript)
}


}