Skip to content

Commit

Permalink
Merge pull request joemphilips#103 from nblockchain/fsharp45-compat
Browse files Browse the repository at this point in the history
Avoid newer F# syntax
  • Loading branch information
joemphilips authored Aug 18, 2020
2 parents 21fb15e + 12d99de commit 7918f43
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build DotNetLightning and deploy to NuGet
name: Build and deploy
on: [push, pull_request]
jobs:
build_and_test:
Expand Down Expand Up @@ -31,3 +31,15 @@ jobs:
- name: Run other tests
run: |
dotnet test
build_with_fsharp_from_mono:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Build
run: |
DEBIAN_FRONTEND=noninteractive sudo apt install -y msbuild fsharp nuget
nuget restore DotNetLightning.sln
msbuild src/DotNetLightning.Core/DotNetLightning.Core.fsproj -p:BouncyCastle=True -p:TargetFramework=netstandard2.0
12 changes: 6 additions & 6 deletions src/DotNetLightning.Core/Payment/PaymentRequest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,16 @@ type FallbackAddress = private {
member this.ToAddress(prefix: string) =
match this.Version with
| 17uy when prefix = "lnbc" ->
let data = Array.concat (seq { [| Helpers.PREFIX_ADDRESS_PUBKEYHASH |]; this.Data })
let data = Array.concat (seq { yield [| Helpers.PREFIX_ADDRESS_PUBKEYHASH |]; yield this.Data })
Helpers.base58check.EncodeData(data)
| 18uy when prefix = "lnbc" ->
let data = Array.concat (seq { [| Helpers.PREFIX_ADDRESS_SCRIPTHASH |]; this.Data })
let data = Array.concat (seq { yield [| Helpers.PREFIX_ADDRESS_SCRIPTHASH |]; yield this.Data })
Helpers.base58check.EncodeData(data)
| 17uy when prefix = "lntb" || prefix = "lnbcrt" ->
let data = Array.concat (seq { [| Helpers.PREFIX_ADDRESS_PUBKEYHASH_TESTNET |]; this.Data })
let data = Array.concat (seq { yield [| Helpers.PREFIX_ADDRESS_PUBKEYHASH_TESTNET |]; yield this.Data })
Helpers.base58check.EncodeData(data)
| 18uy when prefix = "lnbc" || prefix = "lnbcrt" ->
let data = Array.concat (seq { [| Helpers.PREFIX_ADDRESS_SCRIPTHASH_TESTNET |]; this.Data })
let data = Array.concat (seq { yield [| Helpers.PREFIX_ADDRESS_SCRIPTHASH_TESTNET |]; yield this.Data })
Helpers.base58check.EncodeData(data)
| v when prefix = "lnbc" ->
let encoder = Bech32Encoder(Encoders.ASCII.DecodeData("bc"))
Expand Down Expand Up @@ -589,7 +589,7 @@ type PaymentRequest = private {
TaggedFields = this.Tags
Signature = None }
let bin = data.ToBytes()
let msg = Array.concat(seq { hrp; bin })
let msg = Array.concat(seq { yield hrp; yield bin })
Hashes.SHA256(msg) |> uint256

member this.Sign(privKey: Key, ?forceLowR: bool) =
Expand Down Expand Up @@ -645,7 +645,7 @@ type PaymentRequest = private {
if (!remainder <> 0) then
byteCount <- byteCount + 1

seq { (hrp |> Helpers.utf8.GetBytes); (reader.ReadBytes(byteCount)) }
seq { yield (hrp |> Helpers.utf8.GetBytes); yield (reader.ReadBytes(byteCount)) }
|> Array.concat
let signatureInNBitcoinFormat = Array.zeroCreate(65)
Array.blit (sigCompact.ToBytesCompact()) 0 signatureInNBitcoinFormat 1 64
Expand Down
34 changes: 17 additions & 17 deletions src/DotNetLightning.Core/Serialize/Features.fs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ module internal Feature =
}

let private supportedMandatoryFeatures =
seq { Feature.OptionDataLossProtect
Feature.InitialRoutingSync
Feature.OptionUpfrontShutdownScript
Feature.ChannelRangeQueries
Feature.VariableLengthOnion
seq { yield Feature.OptionDataLossProtect
yield Feature.InitialRoutingSync
yield Feature.OptionUpfrontShutdownScript
yield Feature.ChannelRangeQueries
yield Feature.VariableLengthOnion
// TODO: support this feature
// Feature.ChannelRangeQueriesExtended
Feature.OptionStaticRemoteKey
Feature.PaymentSecret
yield Feature.OptionStaticRemoteKey
yield Feature.PaymentSecret
// TODO: support this feature
// Feature.BasicMultiPartPayment
}
Expand All @@ -161,16 +161,16 @@ module internal Feature =

let allFeatures =
seq {
Feature.OptionDataLossProtect
Feature.InitialRoutingSync
Feature.OptionUpfrontShutdownScript
Feature.ChannelRangeQueries
Feature.VariableLengthOnion
Feature.ChannelRangeQueriesExtended
Feature.OptionStaticRemoteKey
Feature.PaymentSecret
Feature.BasicMultiPartPayment
Feature.OptionSupportLargeChannel
yield Feature.OptionDataLossProtect
yield Feature.InitialRoutingSync
yield Feature.OptionUpfrontShutdownScript
yield Feature.ChannelRangeQueries
yield Feature.VariableLengthOnion
yield Feature.ChannelRangeQueriesExtended
yield Feature.OptionStaticRemoteKey
yield Feature.PaymentSecret
yield Feature.BasicMultiPartPayment
yield Feature.OptionSupportLargeChannel
}
|> Set

Expand Down
2 changes: 1 addition & 1 deletion src/DotNetLightning.Core/Serialize/TLVs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type QueryShortChannelIdsTLV =
| QueryFlags (t, flags) ->
let encodedFlags: byte[] =
flags |> Encoder.encodeQueryFlags t
let v = Array.concat(seq { [|(uint8)t|]; encodedFlags })
let v = Array.concat(seq { yield [|(uint8)t|]; yield encodedFlags })
{ Type = 1UL; Value = v }
| Unknown tlv -> tlv

Expand Down

0 comments on commit 7918f43

Please sign in to comment.